Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Escaping parentheses in regexps

by broquaint (Abbot)
on Jan 22, 2003 at 14:54 UTC ( #229029=note: print w/replies, xml ) Need Help??


in reply to Escaping parentheses in regexps

Make use of the either quotemeta or the regex equivalent \Q (see. perlre for more info on \Q). So something like
if ($concat !~ /\Q$string/) { $concat .= " and $string"; }

HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Escaping parentheses in regexps
by scain (Curate) on Jan 22, 2003 at 15:12 UTC
    And, if you are putting other stuff in your regex that you don't want escaped, end the quotemeta with a \E, ie,
    if ($concat !~ /other stuff\Q$string\E more other stuff/) { $concat .= " and $string"; }

    Scott
    Project coordinator of the Generic Model Organism Database Project

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-07-16 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?