http://qs321.pair.com?node_id=1036452


in reply to Remove duplicate from the same line..

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,