in reply to Re^2: Remove duplicate from the same line..
in thread Remove duplicate from the same line..

Adding .* after \1 in Atanasius' solution should do the trick as it matches everything up to the trailing \n.

Replies are listed 'Best First'.
Re^4: Remove duplicate from the same line..
by Anonymous Monk on Jun 01, 2013 at 17:28 UTC
    No, it didnt worked!

      You are not very open to experimentation, are you?

      use strict; use warnings; my $str = "Goldman Sachs Group, ... Goldman Sachs Group, Inc."; $str =~ s/ \b (.+) \b [,.\s]* \1.* /$1/gx; print "$str\n";