Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

help on sed

by Anonymous Monk
on Jun 05, 2003 at 21:08 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-03-28 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found