The following regex will remove any word or phrase that duplicates its immediate predecessor:
$string =~ s/ \b (.+) \b \s* \1 /$1/gx;
But note that an address such as “Long Island City, NY NY” will be reduced to “Long Island City, NY”.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Remove duplicate from the same line.
by Athanasius
in thread Remove duplicate from the same line..
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |