There's more than one way to do things | |
PerlMonks |
Q regex escape within variableby palkia (Monk) |
on Mar 28, 2017 at 08:18 UTC ( [id://1186206]=perlquestion: print w/replies, xml ) | Need Help?? |
palkia has asked for the wisdom of the Perl Monks concerning the following question:
Hello. I tried clustering some file names based on their prefix (those beginning with closers) while ignoring the specific numerical values within them. To achieve this, whenever a desired prefix pattern appeared, I subbed the numerical values with \d++ so it can be used later as a regex pattern, however since the prefix contains closers and possibly other special regex characters, I have sandwiched all non-\d++ parts with \Q and \E, but that raises the error Unrecognized escape \Q passed through in regex; I can't seem to figure what I am missing ? Thank you very much for any assistance, and have an awesome day ☺ Update: resolved by quotemeta(), thx to Eily.
Back to
Seekers of Perl Wisdom
|
|