> -----Original Message----- > From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 26, 2002 11:30 AM > To: todd shifflett; [EMAIL PROTECTED] > Subject: RE: extracting a string from between parens > > > >I have this situation: > > $in = "02 Jul 5.00 (YHZ GA-E)" > > > >I want: > > $out = "YHZGA-E" > > > >How do I extract the information between the ()s ? > >Other than the parens all other characters are likely to change. > > Perhaps > $in =~ /\((.*?)\)/; > $out = $1;
This is a problem if there is no match. $1 will have whatever it's previous value was. Just use match operator in list context: ($out) = $in =~ /\((.*?)\)/; Now $out will be undef if there is no match. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]