例如,匹配"民族报"在""国际化"没有额外的模块,是否有可能在新的Perl版本(5.14,5.15等)?
我找到了答案!感谢tchrist
与UCA匹配的Rigth解决方案(thnx到/sf/users/32989071/).
# found start/end offsets for matched utf-substring (without intersections)
use 5.014;
use strict;
use warnings;
use utf8;
use Unicode::Collate;
binmode STDOUT, ':encoding(UTF-8)';
my $str = "Îñ?érñå?îöñå?îžå?îöñ" x 2;
my $look = "Nation";
my $Collator = Unicode::Collate->new(
normalization => undef, level => 1
);
my @match = $Collator->match($str, $look);
if (@match) {
my $found = $match[0];
my $f_len = length($found);
say "match result: $found (length is $f_len)";
my $offset = 0;
while ((my $start = …
Run Code Online (Sandbox Code Playgroud)