小编nor*_*yno的帖子

如何在perl中匹配字符串与变音符号?

例如,匹配"民族报"在""国际化"没有额外的模块,是否有可能在新的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)

regex unicode perl collation

23
推荐指数
2
解决办法
3049
查看次数

标签 统计

collation ×1

perl ×1

regex ×1

unicode ×1