note 94011 added to intro.pcre
| From: | m dot colombo at NOSPAM dot esi dot it | Date: | Mon, 12 Oct 2009 10:22:58 +0000 |
| Subject: | note 94011 added to intro.pcre | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-161645@lists.php.net to get a copy of this message | ||
Converting POSIX regex patters to PCRE is non-trivial. I had many (about 17.000) patterns stored in
a DB, and found that surrounding one with delimiters (such as '/'), after quoting them, is
not enough.
I've been biten by a \r that slipped into a pattern (that was supposed to be \.r and became .\r
instead). Too bad in PCRE it stands for carriage-return.
AFAIK, there's no way to disable this behaviour and make PCRE more POSIX compatibile. You have
to look for every single escape sequence that has no meaning in POSIX regex but has one in PCRE and
remove the backslash.
Before POSIX regex are removed it would be really cool to have a function that converts a POSIX
regex pattern into the equivalent PCRE one.
----
Server IP: 69.147.83.197
Probable Submitter: 93.34.13.246
----
Manual Page -- http://www.php.net/manual/en/intro.pcre.php
Edit -- https://master.php.net/note/edit/94011
Del: integrated -- https://master.php.net/note/delete/94011/integrated
Del: useless -- https://master.php.net/note/delete/94011/useless
Del: bad code -- https://master.php.net/note/delete/94011/bad+code
Del: spam -- https://master.php.net/note/delete/94011/spam
Del: non-english -- https://master.php.net/note/delete/94011/non-english
Del: in docs -- https://master.php.net/note/delete/94011/in+docs
Del: other reasons-- https://master.php.net/note/delete/94011
Reject -- https://master.php.net/note/reject/94011
Search -- https://master.php.net/manage/user-notes.php