#36442 [Opn->Csd]: preg_match's examples shouldn't always use / as delimiter

From: Date: Sat, 18 Feb 2006 22:44:34 +0000
Subject: #36442 [Opn->Csd]: preg_match's examples shouldn't always use / as delimiter
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969371987@lists.php.net to get a copy of this message
ID: 36442 Updated by: nlopess@php.net Reported By: colder@php.net -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant New Comment: ok, regex improved. Previous Comments: ------------------------------------------------------------------------ [2006-02-18 16:45:48] colder@php.net Rectification: it will work using X PCRE_EXTRA modifier, my bad. ------------------------------------------------------------------------ [2006-02-18 16:41:35] colder@php.net In the examples of other pcre functions, "|" was often used as an alternative. (e.g. http://php.net/preg_match_all http://php.net/preg_replace_callback) The fact that chars used as delimiter must be escaped in the regex is already stated here: http://php.net/pcre#pcre.intro The point is : having to escape a delimiter in the regex is almost always due to a wrong choice of delimiter. So must we demonstrate that wrong choice ? I agree that the alternative could be another char, like "!". But then the examples using "|" could be changed. Is it worth it ? Anyway, the "." escaped in a character class must be changed, because it would fail using the PCRE_EXTRA (X) modifier (I agree that its not ofted used but still ;) ). ------------------------------------------------------------------------ [2006-02-18 16:05:51] arpad@php.net I'm not sure of the merit of using a different delimiter there since it demonstrates that if the delimiter does exist, it should be escaped. However if it is changed, I think '|' is a bad choice because it's part of PCRE syntax. ------------------------------------------------------------------------ [2006-02-18 16:05:49] arpad@php.net I'm not sure of the merit of using a different delimiter there since it demonstrates that if the delimiter does exist, it should be escaped. However if it is changed, I think '|' is a bad choice because it's part of PCRE syntax. ------------------------------------------------------------------------ [2006-02-18 14:48:34] colder@php.net Description: ------------ In the manual page of preg_match, "/" is always used as delimiter, even if there are "/"s in the regex. It could influences bad habbits on readers. There are also too many escaped chars. Here is the patch containing the proposed changes: http://www.colder.ch/patches/preg-match.patch ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36442&edit=1

« previous php.doc (#969371987) next »