Re: preg_match

From: Date: Mon, 22 Aug 2005 15:13:34 +0000
Subject: Re: preg_match
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-221099@lists.php.net to get a copy of this message
On 8/22/05, Richard Lynch <ceo@l-i-e.com> wrote: > On Sat, August 20, 2005 5:00 am, John Nichel wrote: > > Personally, I have never used \\ in PCRE when looking for things like > > spaces (\s), word boundraries (\b), etc. and it's all worked out fine. > > Personally, { > I > } have > never { > used > proper > indenting > in > my > code } and > it's > all > worked > out > fine; > > :-) Unnecessary backslashes make your regular expressions almost as unreadable as those indents. You only ever need to escape a backslash in single-quotes if it's before another backslash or a single-quote. In fact the manual itself explicitly says this: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single So what benefit exactly do you see in doubling up all the backslashes in a single-quoted regexp? It's certainly not helping readability, and they don't actually do anything... -robin

« previous php.general (#221099) next »