Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Perl中如何匹配汉字?为什么
$ perl -e 'if ( "中国" =~ /\p{Han}/ ) { print "!"}' $
不工作?
如果您的源代码是 UTF-8,则需要使用use utf8;. 如果不是 UTF-8,则源中不可能有任何汉字符。
use utf8;
$ perl -le'use utf8; if ( "中国" =~ /\p{Han}/ ) { print "!" }' !