Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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

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's escapeHTML() method...

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

    "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 \.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2023-06-01 17:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found