Matching Han and other double-width characters in regular expressions |
|
1 Chronology1.1 2009-04-22 InFullwidth works, InEastAsianFullwidth maybe not
#!/usr/bin/perl # Time-stamp: <2009-04-22 00:13:43 phm> use Unicode::EastAsianWidth; use utf8; use Encode qw(encode decode); my $str = '網誌'; ($val) = $str =~ m(\A(\p{InEastAsianWide}+)\Z); print encode('UTF-8', $val), "\n"; $str = '123'; ($val) = $str =~ m((\p{InFullwidth}{2}+)); print encode('UTF-8', $val), "\n";
2 Resources |