my @words = qw( SA NV LTD CO LLC ); #### my ($re) = map qr/$_/i, join '|', map quotemeta, @words; #### use Regexp::List qw( ); my $re = Regexp::List->new(modifiers => 'i')->list2re(@words); #### while (<>) { chomp; s/^ (?: $re \s+ )+//x; s/ (?: \s+ $re )+//xg; print("$_$/"); }