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