Unicode::Collate string replacements and case sensitivity
[email protected] (Frank Müller) Thu, 28 Apr 2011 10:06:58 -0700 (PDT)
| Newsgroups | perl.unicode |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <eb390985-0653-427e-a640-723b674367fd@q21g2000vbs.googlegroups.com> |
dear all,
I'm trying to do some string replacements with Unicode::Collate which
usually work very well, but these replacements seem to be case
insensitive by default - how can I change this? look at this simple
example:
my $myCollator =3D Unicode::Collate->new( normalization =3D> undef, level
=3D> 1 );
my $str =3D "Camel camel donkey zebra came\x{301}l CAMEL horse
cAmEL...";
$myCollator->gsubst($str, "camel", sub { "#$_[0]#" });
which makes the following replacements:
#Camel# #camel# donkey zebra #cam=E9l# #CAMEL# horse #cAmEL#...
what I would love to see is the following result:
Camel #camel# donkey zebra #cam=E9l# CAMEL horse cAmEL...
As there doesn't seem to be gsubst for case sensitive and gisubst for
case insensitive string replacements, what would a solution look like?
Thanks a lot for any suggestions,
Frank