#26854 [Bgs]: Using ! as a delimiter for regexps will not allow neg. lookahead assertions
| From: | chris_se at gmx dot net | Date: | Fri, 09 Jan 2004 18:08:00 +0000 |
| Subject: | #26854 [Bgs]: Using ! as a delimiter for regexps will not allow neg. lookahead assertions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53039@lists.php.net to get a copy of this message | ||
ID: 26854
User updated by: chris_se at gmx dot net
Reported By: chris_se at gmx dot net
Status: Bogus
Bug Type: PCRE related
Operating System: Linux
PHP Version: 4.3.4
New Comment:
Even if this is not a bug (in my eyes, it still is), it is at least a
documentation problem:
From http://www.php.net/manual/en/ref.pcre.php:
------------------------------------------------------
The syntax for patterns used in these functions closely resembles Perl.
The expression should be enclosed in the delimiters, a forward slash
(/), for example. Any character can be used for delimiter as long as
it's not alphanumeric or backslash (\). If the delimiter character has
to be used in the expression itself, it needs to be escaped by
backslash.
------------------------------------------------------
From reading this text passage, it is perfectly valid to assume that
what I have assumed.
Previous Comments:
------------------------------------------------------------------------
[2004-01-09 12:57:59] andrei@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
Use a different delimiter instead. The library does not remove
backslashes before delimiters and PCRE doesn't know what to do with
(?\\!).
------------------------------------------------------------------------
[2004-01-09 12:39:04] chris_se at gmx dot net
Description:
------------
When I try to use ! as delimiter and use a negative lookahead assertion
which is normally started with (?!, (?! of course does not work,
because the ! will terminate the pattern (and PHP will of course
complain). But when I try to escape the exclamation mark like (?\!, an
error occurs.
I assume the \ is not removed in front of the ! after the pattern is
freed from its delimiters.
Reproduce code:
---------------
$res = preg_match ("!^(?\\!foo)[a-z]{3}$!", "bar");
Expected result:
----------------
$res contains true
Actual result:
--------------
Warning: Compilation failed: unrecognized character after (? at offset
3 in /home/christian/- on line 2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26854&edit=1