Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Search and Replace Regex

by andrew (Acolyte)
on Aug 21, 2002 at 23:07 UTC ( [id://191888]=perlquestion: print w/replies, xml ) Need Help??

andrew has asked for the wisdom of the Perl Monks concerning the following question:

I need to poll some information after I search and replace, say my line contains "abcdbab (djdjdj) aa", how can I "just" get the infomation in the middle of ()'s. SO basically $wah would contain "djdjdj".

Replies are listed 'Best First'.
Re: Search and Replace Regex
by fokat (Deacon) on Aug 21, 2002 at 23:38 UTC
      For which reason, specifically? AFAIK, the only difference is that /X(.*?)Y/ doesn't match newlines, whilst /X([^Y]*)Y/ does. --Dave
Re: Search and Replace Regex
by dpuu (Chaplain) on Aug 21, 2002 at 23:21 UTC
    $line =~ /\((.*?)\)/ and $wah = $1
    --Dave

    Update: oops: I forgot the capturing parentheses

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found