my $test = "asd asd"; if ($test =~ /(.+\b)\s\1/) { print "Found $1 repeated\n"; }