判读字符串中是否含有中文

pattern 和matcher 都是jdk中的
import java.util.regex. Matcher
import java.util.regex. Pattern
public static boolean isContainChinese ( String str) {
Pattern p = Pattern . compile ( "[\u4e00-\u9fa5]" ) ;
Matcher m = p.matcher (str)
if ( m.find ()) {
return true ;
}
return false ;
}

猜你喜欢

转载自blog.csdn.net/qq_38380025/article/details/80433982
今日推荐