use strict; my $tstr = 'abc äÄöÖüÜß test'; my %subsTable = ( 'ä' => 'ae', 'Ä' => 'AE', 'ö' => 'oe', 'Ö' => 'OE', 'ü' => 'ue', 'Ü' => 'UE', 'ß' => 'ss' ); my $notInSQL = qr{['`´",%\$]}; my $inSQL = qr{[`´",\$]}; sub blah { my $str = shift; my $regex = join "", map { quotemeta $_ } keys %subsTable; $regex = "[$regex]"; print "Regex: $regex\n"; $str =~ s/($regex)/$subsTable{$1}/g; return $str }; print "orig : $tstr\n"; print blah($tstr)."\n";