Dr.Ruud wrote:
Gunnar Hjalmarsson schreef:
Dr.Ruud:
Ravi Malghan:
I want to extract data between the first parenthesis and the last
in the below variable.
<snip>

$OrigString =
"REQUEST(SERVICE,1DJGHKDFJGHDFJGHKDFJH\nDFJHGDFJHGJDFHGJKDFHG\nHGJDFHGJK DFHGJKDFHGJKDFH);";
$OrigString =~ m/REQUEST\((.*)\);/;
print "$1\n";
Read perlre, about the s-modifier. I also added non-greediness.

  $OrigString =~ m/REQUEST\((.*?)\);/s;
Since the OP wants to extract everything up to the _last_ parenthesis,
non-greediness is not really applicable, is it?

That is exactly why I explicitely mentioned it. If the data can contain
a (closing!) parenthesis, adjust.

That does not explain why you introduced non-greediness in the first place.

Was my "Or use this variant" really not clear enough for you? I don't
believe so.

Now I don't follow you. The variant is indeed clear to me, but I don't see how the fact that you posted it would motivate your introducing of non-greediness in the first suggestion.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to