Re: preg_match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/22/05, Richard Lynch <ceo@xxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux