use strict; use warnings; my $s = 'This is a test'; my @pairs = $s =~ /(?=(\w+ \s+ \w+))\w+ \s+/gx; print join "\n", @pairs;