raptor has asked for the wisdom of the Perl Monks concerning the following question:
sub blah { $_ = shift; s/ä/ae/g; s/Ä/AE/g; s/ö/oe/g; s/Ö/OE/g; s/ü/ue/ +g; s/Ü/UE/g; s/ß/ss/g; $_ }
these are not all symbols to be converted I'm expecting more to come...$tstr = 'abc äÄöÖüÜß test'; %subsTable = ( 'ä' => 'ae', 'Ä' => 'AE', 'ö' => 'oe', 'Ö' => 'OE', 'ü' => 'ue', 'Ü' => 'UE', 'ß' => 'ss' ); $notInSQL = qr{'|`|´|"|,|%|$}; $inSQL = qr{`|´|"|,|$}; sub blah { my $str = shift; my $regex = join "|", map quotemeta, keys %subsHash; print $regex,"\n"; $regex = qr/$regex/; $str =~ s/($regex)/$subsHash{$1}/g; # if ($str =~ /^\s*(SELECT|INSERT|UPDATE|DELETE)/i ) { $str =~ s/$i +nSQL/ /g } # else { $str =~ s/$notInSQL/ /g }; #may be have to use tr/// here return $str }; print "orig : $tstr\n"; print blah($tstr)."\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: transliterating.. char-conversation
by Ovid (Cardinal) on Aug 08, 2001 at 00:32 UTC | |
by raptor (Sexton) on Aug 08, 2001 at 00:48 UTC | |
|
Re: transliterating.. char-conversation
by raptor (Sexton) on Aug 08, 2001 at 00:27 UTC |