my $string_two = 'foo bar [21a] plus (23b) baz bax'; my @string_two_results = $string_two =~ m{ (\d+) (a|b) }gx; print "RESULTS: " , Dumper(\@string_two_results), $/; # RESULTS: $VAR1 = ['21','a','23','b'];