develooper Front page | perl.unicode | Postings from April 2011

Unicode::Collate string replacements and case sensitivity

Thread Next
From:
=?ISO-8859-1?Q?Frank_M=FCller?=
Date:
April 29, 2011 02:21
Subject:
Unicode::Collate string replacements and case sensitivity
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 = Unicode::Collate->new( normalization => undef, level
=> 1 );
my $str = "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él# #CAMEL# horse #cAmEL#...

what I would love to see is the following result:

Camel #camel# donkey zebra #camél# 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


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About