#50615 [Bgs]: preg_match() error
| From: | jzumbrun at gmail dot com | Date: | Thu, 31 Dec 2009 15:30:36 +0000 |
| Subject: | #50615 [Bgs]: preg_match() error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146245@lists.php.net to get a copy of this message | ||
ID: 50615
User updated by: jzumbrun at gmail dot com
Reported By: jzumbrun at gmail dot com
Status: Bogus
Bug Type: Regexps related
Operating System: OsX 10.6.1
PHP Version: 5.3.1
New Comment:
Thanks for the clarity and for the quick response.
Unfortunately I spent quite a bit of time trying to make the
preg_match() work with / by hand not knowing that preg_match() had a
configurable regex separator character. I can only find this in the
preg_quote() documentation. I would be supper nice if the preg_match()
docs mentioned you can change the regex separator character.
Previous Comments:
------------------------------------------------------------------------
[2009-12-31 04:23:44] rasmus@php.net
Oh, and it is documented. Look at the description of the optional 2nd
delimiter argument.
------------------------------------------------------------------------
[2009-12-31 04:21:50] rasmus@php.net
The manual doesn't specifically talk about / because the regex
separator character is completely configurable. If you use another
char, like ~ for example, then you don't have to escape the /
eg.
preg_match("~$urlClass~", $line);
------------------------------------------------------------------------
[2009-12-31 02:19:37] jzumbrun at gmail dot com
Description:
------------
// $line equals line below from file:
$route['infox/(.*)'] = "articles/$1";
Basically I have to manually put an \ in front of the / char after
infox. preg_quote() wont escape it and the documentation doesnt say i
need to escape / chars. preg_match() is forcing me to put one there.
Reproduce code:
---------------
---
From manual page: function.preg-quote
---
$urlClass = '\$route\['infox'/\(\.\*\)'\]';
preg_match("/$urlClass/", $line);
Expected result:
----------------
no errors
Actual result:
--------------
Message: preg_match() [function.preg-match]: Unknown modifier '\'
if i use $urlClass = '\$route\['infox'\/\(\.\*\)'\]';
it works (notice the \ infront of the 3rd char after infox)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50615&edit=1