Keep It Simple, Stupid | |
PerlMonks |
regex matching on metacharactersby slugger415 (Monk) |
on Jul 20, 2022 at 23:56 UTC ( [id://11145616]=perlquestion: print w/replies, xml ) | Need Help?? |
slugger415 has asked for the wisdom of the Perl Monks concerning the following question: Hi all, sorry if this is a naive question but I've searched around the web and haven't found a good answer, including https://perldoc.perl.org/perlre#Metacharacters. How do I match a regex that contains metacharacters that are used in matching, such as asterisks, parens, etc.? Without escaping each? I have two variables set, both containing asterisks, and a regex comparison:
This obviously results in a Quantifier follows nothing in regex error. I can escape out the asterisk and it works fine:
But is there a more elegant way to do that, one that might also pick up some of the others? thanks
Back to
Seekers of Perl Wisdom
|
|