Bug #71036 [Opn->Ver]: When using /x modifier, a "/" in a regex comment is seen as a regex delimiter

From: Date: Sat, 05 Dec 2015 01:55:00 +0000
Subject: Bug #71036 [Opn->Ver]: When using /x modifier, a "/" in a regex comment is seen as a regex delimiter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197606@lists.php.net to get a copy of this message
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)

« previous php.bugs (#197606) next »