|
Posted by Robin Vickery on 08/22/05 18:13
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
[Back to original message]
|