in reply to Re: Duplicate Words
in thread Duplicate Words

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

Replies are listed 'Best First'.
Re: Re: Re: Duplicate Words
by Anonymous Monk on Apr 20, 2001 at 17:57 UTC
    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;