|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-04-05 16:48 UTC] cmb@php.net
[2018-04-05 21:44 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2018-04-05 21:44 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
Description: ------------ In regular expressions an unescaped minus character (-) in character classes is usually used to declare a range. However when the range makes no sense, it is treated as a literal minus character. This seems still to be true for most occasions in 7.3-dev except for one special combination, where the minus sits between a shortcut character class and a dollar sign. Eg. /[\w-$]/. Previous PHP versions would treat this as word characters, minus and dollar. PHP 7.3-dev throws an error. Test script: --------------- <?php $tests = [ '/[\w-$]/', '/[\w-]/', '/[-\w]/', '/[$-]/', '/[-$]/', ]; echo PHP_VERSION; echo "\n"; foreach($tests as $test) { echo "$test\n"; preg_match($test,''); } Expected result: ---------------- 7.2.3 /[\w-$]/ /[\w-]/ /[-\w]/ /[$-]/ /[-$]/ Actual result: -------------- 7.3.0-dev /[\w-$]/ Warning: preg_match(): Compilation failed: invalid range in character class at offset 3 in /var/www/test.php on line 16 /[\w-]/ /[-\w]/ /[$-]/ /[-$]/