On Feb 14, Bill Akins said:

>I have a string that is read in and assigned to a veriable.  String
>looks something like this:
>10.00 c$cpi  c$ul  (Sample Number:) c$sh  /Courier 0 c$fnt  (
>SA-01-0C8A8) c$sh ( ) c$sh  /Courier 0 c$fnt
>
>I need the string between the second set of ()'s.  There may or may not
>be a leading space, if so, I need to strip it out.  There are not the
>exact same number of charecters in the string, the only thing constant
>is the value I need is in the second set of ()'s.

You can match it like so:

  my ($second_paren) = ($string =~ /\((.*?)\)/g)[1];

or

  my ($second_paren) = ($string =~ /\(([^)]*)\)/g)[1];

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to