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