[wikka-community] Coding guideline about backslash.

Marjolein Katsma javawoman
Tue Oct 9 22:20:41 GMT 2007


Oops, I wanted to correct but hit the "send" a bit too early...

At 21:17 2007-10-09, I wrote:
>1. If you want a regex to test a string starting with the 2 characters \
>and n, you don't need to write '/^\\\\n/' - instead, you could write
>'/^[\]n/' : using a character class to represent the single backslash.

That should read:

If you want a regex to test a string starting with the 2 characters \
and n, you don't need to write '/^\\\\n/' - instead, you could write
'/^[\\]n/' : using a character class to represent the single backslash -
while still escaping it once (otherwise the engine would assume it's
the  ] being escaped); that gets rid of at least one level of escaping.

Cheers,



--
JavaWoman
Web Standards Compliance Officer, Wikka Development Crew
http://wikkawiki.org/JavaWoman
Skype: callto://goneagain





More information about the community mailing list