([^]+) \(([0-9]+).*\) ([a-z]+) On Mar 8, 2014 1:07 AM, "Bill McCormick" <[email protected]> wrote:
> I have the following string I want to extract from: > > my $str = "foo (3 bar): baz"; > > and I want to to extract to end up with > > $p1 = "foo"; > $p2 = 3; > $p3 = "baz"; > > the complication is that the \s(\d\s.+) is optional, so in then $p2 may > not be set. > > getting close was > > my ($p1, $p3) = $str =~ /^(.+):\s(.*)$/; > > How can I make the " (3 bar)" optional. > > Thanks! > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > > -- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > http://learn.perl.org/ > > >
