zhk2369 发表于 2017-5-19 11:57:20

怎样用正则表达式匹配汉字 (perl)

转成unicode以后用property匹配,例(设输入输出编码为gb2312、gbk或gb18030):

use Encode;
$_="abc你好wert";
$a=decode('cp936',$_);
($x)=($a=~m/(\p{Han}+)/);
print encode('cp936',$x),"\n";
页: [1]
查看完整版本: 怎样用正则表达式匹配汉字 (perl)