in reply to g matching after a single regular match

You should be able to do it with a global match with an alternation in the pattern.

use strict; use warnings; my @strings = ( q{1.2.3AAABB,AAB,AA,AAABBB}, q{AABB,AAAB,ABBB}); foreach my $string ( @strings ) { print qq{$string\n}; my @elems = $string =~ m{ ( \d(?:\.\d)* | A+ | B+ ) }gx; print qq{ qw(@elems)\n}; }

The output is

1.2.3AAABB,AAB,AA,AAABBB qw(1.2.3 AAA BB AA B AA AAA BBB) AABB,AAAB,ABBB qw(AA BB AAA B A BBB)

Cheers,

JohnGG