in reply to A misunderstanding of quotemeta ?
Hello syphilis,
From quotemeta:
quotemeta (and \Q ... \E) are useful when interpolating strings into regular expressions, because by default an interpolated variable will be considered a mini-regular expression.
So, the purpose of using \Q is to prevent “special” characters from having their special (overloaded) meanings within regular expressions. And this is done by backslashing the characters:
... all ASCII characters not matching /[A-Za-z_0-9]/ will be preceded by a backslash in the returned string, ...
Now, in a substitution, only the left-hand side is a regex; the right-hand side is simply the replacement text. So it makes no sense to “de-regexify” the special characters on the right-hand side; they have no special regex meaning in this position anyway. But if you do apply \Q, of course the non-word characters are backslashed, as you are seeing.
That’s my understanding, anyway. Hope it helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|