Bug #70764 [Opn->Nab]: preg_match generate different results
| From: | rasmus@php.net | Date: | Thu, 22 Oct 2015 04:56:40 +0000 |
| Subject: | Bug #70764 [Opn->Nab]: preg_match generate different results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196737@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70764&edit=1
ID: 70764
Updated by: rasmus@php.net
Reported by: zhihong dot chen dot cn at gmail dot com
Summary: preg_match generate different results
-Status: Open
+Status: Not a bug
Type: Bug
Package: PCRE related
Operating System: ubuntu 14.04
PHP Version: 5.6.14
Block user comment: N
Private report: N
New Comment:
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/
Previous Comments:
------------------------------------------------------------------------
[2015-10-22 02:43:42] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70764&edit=1