in reply to Multiple Regex, it works but it aint clever
use a hash!? and: what do you need the parentheses for?
sub format { my %replace = ( ' & CO [^,]+' => ' AND CO', '&' => 'AND', #followed by [^,]+ map( {( quotemeta($_).'[^,]+' , '' )} #leading space map(" $_", qw/EUR1 EUR2 EUR4 EUR8 EUR0. CHF Y5 LTD INTL/, 'NV ','FIN ' ), #no leading space '$','NON-CUM' ), '\s+$' => '', #others... ); # search longest first for(reverse sort keys %replace){ $long =~ s/$_/$replace{$_}/g; #/g seems usefull } }
edit: missing replacement for '\s+$' added
--
|
|---|