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