my $string = "one two three four"; $string =~ s/^((?:\w+\s+){2})(\w+)\s+\b/$1/; my $word = $2; print "$string, $word\n";