in reply to 1000000th question about regex lol
No. Your program does not add / signs.
It adds backslashes (\ "signs"), and this is unsurprising:
$X =~ s/\Q$A\E/\Q$B\E/g; # THIS IS NOT RIGHT
On the replacement side of s///, \Q and \E apply quotemeta to the replacement string.
You want quotemeta only on the regex side of s/// to escape all regex meta characters, and usually never on the replacement side.
If you leave them out, you get the plain replacement:
$X =~ s/\Q$A\E/$B/g; # THIS IS NOT RIGHT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 1000000th question about regex lol
by harangzsolt33 (Deacon) on Dec 07, 2019 at 15:26 UTC |