in reply to Re: regexp - repeatedly delete words expressed in alternation from end of string
in thread repeatedly delete words expressed in alternation from end of string [regexp]
my @words = qw( SA NV LTD CO LLC ); my ($re) = map qr/$_/i, join '|', map quotemeta, @words; while (<DATA>) { chomp; s/(?:\s*\b$re)+$//; print "[$_]\n"; } __END__ Bobs leave SA Warehouse SA LTD Jims Fine Wines CO LLC
|
---|