Bug #81060 [Com]: The expression does not compile correctly
| From: | imsop@php.net | Date: | Thu, 20 May 2021 17:26:33 +0000 |
| Subject: | Bug #81060 [Com]: The expression does not compile correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233931@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81060&edit=1
ID: 81060
Comment by: imsop@php.net
Reported by: vklimin at 510710 dot com
Summary: The expression does not compile correctly
Status: Not a bug
Type: Bug
Package: PCRE related
Operating System: Debian 10
PHP Version: 8.0.6
Block user comment: N
Private report: N
New Comment:
My apologies, I see that \Q and \E change the meaning of the escape there.
However, they *don't* change the handling of the delimiter, as that happens before the regex is
even passed to PCRE.
In other words, PCRE receives the regex \Q/\E and the modifiers \E/ hence the error message.
Previous Comments:
------------------------------------------------------------------------
[2021-05-20 17:17:55] vklimin at 510710 dot com
The proposed solution is not correct
var_dump( preg_match( '/\Q\/\E/', '/' ) );
Expected result:
----------------
int(1)
Actual result:
--------------
int(0)
------------------------------------------------------------------------
[2021-05-20 17:14:01] imsop@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The first character of the regex determines the delimiter; any extra instances of that delimiter
need to be escaped.
var_dump( preg_match( '/\Q\/\E/', '/' ) );
------------------------------------------------------------------------
[2021-05-20 17:09:51] vklimin at 510710 dot com
Changed the name of the corresponding package
------------------------------------------------------------------------
[2021-05-20 17:07:16] vklimin at 510710 dot com
Description:
------------
The expression does not compile correctly and generates a warning.
Test script:
---------------
var_dump( preg_match( '#\Q/\E#', '/' ) );
var_dump( preg_match( '/\Q/\E/', '/' ) );
Expected result:
----------------
int(1)
int(1)
Actual result:
--------------
int(1)
Warning: preg_match(): Unknown modifier '\' in [...][...] on line 1
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81060&edit=1