$string =~ s/((?:\w+\s+){2})/$1$word /;