|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-10-22 02:43 UTC] zhihong dot chen dot cn at gmail dot com
Description:
------------
var_dump(preg_match('/^\+?[\d\(\)-\s]+$/','18600003005'));
should generate true.
in 5.3.28, it generate true
Test script:
---------------
<?PHP
var_dump(preg_match('/^\+?[\d\(\)-\s]+$/','18600003005'));
Expected result:
----------------
true
Actual result:
--------------
false
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 13:00:02 2026 UTC |
As the warning tells you, that regex is wrong. Warning: preg_match(): Compilation failed: invalid range in character class at offset 13 You are doing a character class range which is something like [a-z] but in your case you have [\d\(\)-\s] which makes no sense. A good way to debug regular expressions like this is to use https://regex101.com/