(I don't like using $& and friends.) (Update: Also, the regex assumes the second parenthetic group has no nested parentheses!)c:\@Work\Perl\monks>perl -wMstrict -le "my $sentto = 'Fred Flintstone (US) (fredf@gmail.com)'; ;; my $captured = my ($first, $second) = $sentto =~ m{ \A (.*) \s+ ([(] [^(]* [)]) \z }xms; ;; if ($captured) { print qq{first '$first' second '$second'}; } else { warn 'parse failed'; } " first 'Fred Flintstone (US)' second '(fredf@gmail.com)'
Give a man a fish: <%-{-{-{-<
In reply to Re: Need regexp to pick off second parenthetical item
by AnomalousMonk
in thread Need regexp to pick off second parenthetical item
by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |