my $line = 'marker '; my $rex = qr/(?:^marker\s|\G)<(.*?)>(?: |$)/; my @matches = ($line =~ /$rex/g);