Multiple stages might be easier to understand but you could reduce the steps using character classes and quotemeta. The following uses one statement but the map inside the quote construct really means there's two stages still being used.
use strict; use warnings; use 5.010; my $ptext = q{"dasj{ah'h'w*jh}wcv'}; say $ptext; $ptext = quotemeta qq{@{ [ map { s{(?x) (?: ^ ["'] | ["'] $ ) }{}g; $_; } $ptext ] }}; say $ptext;
The output.
"dasj{ah'h'w*jh}wcv' dasj\{ah\'h\'w\*jh\}wcv
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Regexp and metacharacters
by johngg
in thread Regexp and metacharacters
by Largins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |