Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Answer: How do I escape special characters like . / or in a regular expression?

by Codmate (Novice)
on Aug 29, 2001 at 16:07 UTC ( #108735=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I escape special characters like . / or | in a regular expression? - Answer contributed by Codmate

It is possible to use another character (other than "/") to make a regex. A hash symbol can be used for example:
$changeme = "/this/url/would/be/a/nightmare/in/regex/"; $changeme =~ s#would/be#is/not#;
You can also escape all special characters in a regex with "\Q" and "\E" like this:
$changeme = "/this/url/wo*ld/b^e/a/nightmare/in/regex/"; $changeme =~ s/\Qwo*ld/b^e\E/\Qis/not\E/;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2016-12-10 15:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (163 votes). Check out past polls.