First, do a substitution like s/\\\\/\\x5c/g or something like that. Then, it's easy to match unescaped charaters, as you only have to check if there's a backslash behind it or not. This substitution can later be reversed if it's needed.
(Using a double backslash as an escape sequece for backslashes is a very silly thing, even though C does that and everyone since blindly follows. There should have been an single-letter escape sequence like \B for backslash, to avoid all this exponential backlash growth thing.)
Update 2008 aug 29: see also Replace only unescaped metachars.
Update 2009 mar 31: see also Re^2: Game Nicknames to HTML.
In reply to Re: checking interpreted string for escapes versus literal backslashes?
by ambrus
in thread checking interpreted string for escapes versus literal backslashes?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |