Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Should I escape all chrs in a regex?

by james2vegas (Chaplain)
on Sep 29, 2010 at 02:08 UTC ( [id://862535]=note: print w/replies, xml ) Need Help??


in reply to Should I escape all chrs in a regex?

You can use quotemeta or \Q \E regex escapes to be sure, like this:
my $match = quotemeta('tftp>'); if ($str =~ /$match/) { ... }
or
my $match = 'tftp>'; if ($str =~ /\Q$match\E/) { ... }
or using the value directly
if ($str =~ /\Qtftp>\E/) { ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://862535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found