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

From: Date: Sat, 05 Dec 2015 01:28:57 +0000
Subject: Bug #71036 [Opn]: 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-197603@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 User updated by: cmanley at xs4all dot nl 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 Type: Bug Package: PCRE related Operating System: Debian 8.2 -PHP Version: 5.6.16 +PHP Version: 5.6.14-0+deb8u1 Block user comment: N Private report: N New Comment: . Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#197603) next »