Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

help on sed

by Anonymous Monk
on Jun 05, 2003 at 21:08 UTC ( #263509=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hello everyone I am having a lil difficuilty in doing this sed line in a perl script. I have a string which looks like this /topics/topics.jsp?&top=Education+Resources i already have a regex which escapes the "/" but how can i escape the other special characters like +, ?, = and so on please help

Comment on help on sed
Re: help on sed
by sauoq (Abbot) on Jun 05, 2003 at 21:20 UTC

    "Escape" meaning what, exactly?

    If you want to escape it for use in a URL have a look at URI::URL's equery() method. If you want to escape it for use in a regex, take a look at the quotemeta() function and the \Q and \E escapes. (Info in perldoc perlre.) If you want to escape it for use in HTML, use CGI.pm's escapeHTML() method...

    If you want something else, you'll need to be more specific.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: help on sed
by arturo (Vicar) on Jun 06, 2003 at 01:51 UTC

    If you're talking about escaping characters that have special meaning inside a regex, what you're looking for is \.
    perlre
    perlretut

    If not P, what? Q maybe?
    "Sidney Morgenbesser"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://263509]
Approved by sauoq
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-10-21 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls