A look-ahead might be faster, but this still doesn't address the question of \ (backslash) handling raised by Corion below.
c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'foo\bar\[baz[x]x{x}x~x*x?x[]{}~*?'; print qq{'$s'}; ;; $s =~ s{ (?= [][{}~*?]) }{\\}xmsg; print qq{'$s'}; " 'foo\bar\[baz[x]x{x}x~x*x?x[]{}~*?' 'foo\bar\\[baz\[x\]x\{x\}x\~x\*x\?x\[\]\{\}\~\*\?'
In reply to Re^2: Faster way to regex this
by AnomalousMonk
in thread Faster way to regex this
by jar00n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |