in reply to Regexp and metacharacters

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

Replies are listed 'Best First'.
Re^2: Regexp and metacharacters
by Largins (Acolyte) on Dec 27, 2011 at 01:21 UTC

    I like the looks of this
    Previous response as well
    Will try both and report back after attempting to run say 10000 files or so