bliako has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monkees
I want to replace a string with another string which contains (lots of) @, [, ( etc. which have special meaning in Perl and definetely I don't want them to be interpolated.
I can use the q{} function to quote these but how can I call it inside the regular expression, e.g. $xx =~ s/<%xpath%>/\Qq{//div[@id="abc"]}\E/e (does not recognize q{}).
bw, bliako
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Elegant way to escape a string in a regex
by hippo (Archbishop) on Apr 14, 2025 at 21:24 UTC | |
by bliako (Abbot) on Apr 14, 2025 at 22:31 UTC | |
by LanX (Saint) on Apr 14, 2025 at 23:34 UTC | |
by Anonymous Monk on Apr 15, 2025 at 19:44 UTC | |
Re: Elegant way to escape a string in a regex
by ikegami (Patriarch) on Apr 14, 2025 at 18:25 UTC | |
by bliako (Abbot) on Apr 14, 2025 at 19:22 UTC | |
by ikegami (Patriarch) on Apr 14, 2025 at 19:34 UTC |