Bug #71036 [Opn->Ver]: When using /x modifier, a "/" in a regex comment is seen as a regex delimiter
Edit report at https://bugs.php.net/bug.php?id=71036&edit=1
ID: 71036
Updated by: requinix@php.net
Reported by: cmanley at xs4all dot nl
Summary: When using /x modifier, a "/" in a regex comment is
seen as a regex delimiter
-Status: Open
+Status: Verified
Type: Bug
Package: PCRE related
Operating System: Debian 8.2
PHP Version: 5.6.14-0+deb8u1
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2015-12-05 01:28:57] cmanley at xs4all dot nl
.
------------------------------------------------------------------------
[2015-12-05 01:26:32] cmanley at xs4all dot nl
Description:
------------
The documentation for the x (PCRE_EXTENDED) modifier states:
"characters between an unescaped # outside a character class and the next newline character,
inclusive, are also ignored"
Yet this is not the case in my test example:
The "/" in the regex comment "# firstname/alias" is seen as a regex delimiter.
Test script:
---------------
<?php
$fullname = 'Joe Blow';
if (preg_match('/^
(\S+) # firstname/alias
\s+
\S+ # surname
$/x', $fullname, $matches)) {
print $matches[1] . "\n";
}
Expected result:
----------------
Joe
Actual result:
--------------
PHP Warning: preg_match(): Unknown modifier 'a' in /home/cmanley/t.php on line 8
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71036&edit=1
Thread (4 messages)