in reply to Duplicate Words

s/(homework\s*){2}/homework /;

Replies are listed 'Best First'.
Re: Re: Duplicate Words
by bent (Scribe) on Apr 20, 2001 at 03:51 UTC
    Hmm,
    What about:
    s/(\b\w+?\b)\s+\1/$1/g;
    This will match "This is a sentence sentence." as well as "This is a sentence sentence to.".
    bent
      If you want to remove dup words from anywhere in the string rather than just consecutive duplicates, try:

      s/\w+\s*/$words{$&}++?'':$&/ge;
      or to ignore case:

      s/\w+\s*/$words{"\L$&"}++?'':$&/ge;