I want a Perl regular expression that will match duplicated words in a string.
Given the following input:
$str = "Thus joyful Troy Troy maintained the the watch of night..."
Thus joyful [Troy Troy] maintained [the the] watch of night...
$str =~ s/\b((\w+)\s+\2)\b/[\1]/g;