in reply to checking interpreted string for escapes versus literal backslashes?

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.

Replies are listed 'Best First'.
Re^2: checking interpreted string for escapes versus literal backslashes?
by Anonymous Monk on Mar 28, 2006 at 16:23 UTC
    that's a good point, i think i'll borrow your \B idea and use it instead! perl should really include something along that line, because i cant remmber how many times i have to deal with "\\\\\$test" or a similar situation...

      Don't actually use \B though, as it's already a regexp meta-character. Better use some unused letter (though it's hard to find any).