Thanks. I did not know the last one you gave (s{...}'//div[@id="abc"]'). I should not have used \Q\E then. I did use it in case there were things like $1 in the replacement string. But q{//div=[@id="$1"]} gives no problem and escapes that too.
So, just to confirm, q{} is absolutely safe for providing a substitution string which nothing in it will be interpreted by the regex (e.g. $1) or by perl (e.g @id): all contents of q{} will be literal, nothing interpreted.
In reply to Re^2: Elegant way to escape a string in a regex
by bliako
in thread Elegant way to escape a string in a regex
by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |