Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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
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
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 cooling their heels in the Monastery: (4)
As of 2015-11-26 05:43 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (696 votes), past polls