in reply to Re: string replacement
in thread string replacement
my $pattern = join "|", map quotemeta, keys %replacements;
I think it would be good to also sort on length, as I discussed in Building Regex Alternations Dynamically. Although huck does make a good point that preserving the original ordering may be important too. Update after your reply: Good point about replacements within the replacements, whether the OP wants that or not and which method is more appropriate will depend on their requirements.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: string replacement
by Eily (Monsignor) on Sep 12, 2017 at 20:44 UTC |
In Section
Seekers of Perl Wisdom