in reply to Re: Replace only unescaped metachars
in thread Replace only unescaped metachars
It makes sure that only unescaped metachars are converted (all preceding escapes are even).(?<!\\) ((?:\\{2})*)
If I see it right, both versions try to keep the common case at the beginning and have to walk through the other regexes until the first match. (Besides the 'redo' irritated me until I read in the docs that it doesn't redo do-blocks) But still thank you very much for this too, it is always good to have variations at hand.for ($string) { $result .= $1 if /\G ([^\\*?]+) /xgcs; /\G \\(.) /xgcs && do { $result .= $1; redo; }; /\G \* /xgcs && do { $result .= '?'; redo; }; /\G \? /xgcs && do { $result .= '#'; redo; }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Replace only unescaped metachars
by ikegami (Patriarch) on Feb 23, 2007 at 17:42 UTC |