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?
[dazz]: Hi I have grabbed an image from an IP camera with Image::Grab. I then want to pass that image object to a subroutine where I do a read-only test on the image with Image:Magick.
[dazz]: How do I pass an image object to a subroutine and then apply a Image::Magick a read-only method to the image object???
[dazz]: Also, I want to use Image::Magick to annotate and composite (not in a sub). How do I take a Image::Grab object and apply Image::Magick write methods to it??
[dazz]: At present, I am saving the Image::Grab image to disk, then creating a new Image::Magick object that reads the disk file.
[dazz]: .
[choroba]: Discipulus Sounds interesting. Any pictures of the puppets or paintings?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-03-27 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (317 votes). Check out past polls.