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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/