Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Answer: How do I escape meta-characters in a user-defined string?

by btrott (Parson)
on Mar 25, 2000 at 01:05 UTC ( #6103=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I escape meta-characters in a user-defined string? - Answer contributed by btrott

if($string=~/\Q$key\E/){
Quotes the metacharacters.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2016-09-26 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (475 votes). Check out past polls.