Here's one way.
$_="alpha beta beta gamma gamma gamma"; while (s/((\w+)\s\2)/$2/) {}; print $_;
the second line does something that may not be obvious to everyone, and seems to duplicate /g 's functionality. However, since you've (seemingly) got 3 gamma in a row, writing
$_="alpha beta beta gamma gamma gamma"; s/((\w+)\s\2)/$2/g; print $_;
Will leave you with an extra gamma. Using the 'useless' while loop allows the regex to check for multiple duplicates.

As for the regex you tried $string =~ s/(\w+)(.*)\b\1/$1 $2/sig;, we have :