my @submatch; { $str =~ /(text);/g or last; push @submatch, $1; for( 1 .. 4 ) { $str =~ /\G(?:(float)[non-num])/g or do { @submatch = (); last; } push @submatch, $1; } }