in reply to using an RE to consolidate repeated words
$after =~ s#^(\w+)/\1#$1#;
Tidying up the syntax and changing the test for the bit in between the repeats gives:
I assumed that there is no need to anchor the pattern to the start of the string so I removed the ^$after =~ s/(\w+)\W+\1/$1/;
|
|---|