One way would be:
>perl -wMstrict -le "my $s = 'ABC1D A2D D3A foo4bar'; my @matches = $s =~ m{ A (?: BC)? (\d+) D }xmsg; print qq{'$_'} for @matches; " '1' '2'
Updates:
In reply to Re: how to make // not return what is in a parenthesis?
by AnomalousMonk
in thread how to make // not return what is in a parenthesis?
by beanryu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |