in reply to Re: efficient char escape sequence substitution
in thread efficient char escape sequence substitution

That doesn't handle wide-character escapes.

In comp.lang.perl.misc I recently offered this solution.

s/(\\[^"\$\@]+)/qq("$1")/eeg;

Note that's not 100% infalible but AFAIK it's not a security problem and copes with all reasonable strings. It does have the interesting side effect of stripping \$ \" and \@ - but those have no buisness being in most of the sort of strings you'll encounter.

Replies are listed 'Best First'.
Re^3: efficient char escape sequence substitution
by Roy Johnson (Monsignor) on May 28, 2005 at 21:42 UTC
    How wide is a wide character escape? There's no reason that you can't change the quantifier in my regex to accommodate them. I just wasn't aware of any escapes wider than three characters.

    Caution: Contents may have been coded under pressure.
      I don't think there's a fixed maximum \N{WHITE SMILING FACE}.