需要一个判断字符串中有没有中文的正则表达式

koalapheonix 2009-07-13 08:58:44
需要一个判断字符串中有没有中文的正则表达式,如果有就返回真,没有返回假
...全文
216 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
The-Venus 2009-07-14
  • 打赏
  • 举报
回复
2楼正解!
nzz1985 2009-07-14
  • 打赏
  • 举报
回复
顶 1楼,2楼
sd01397055 2009-07-14
  • 打赏
  • 举报
回复
学习,Pattern 和Matcher类
noone_1983 2009-07-13
  • 打赏
  • 举报
回复
这样可以

static String regEx = "[\u4e00-\u9fa5]";
static Pattern pat = Pattern.compile(regEx);

public static boolean isContainsChinese(String str)
{
Matcher matcher = pat.matcher(str);
boolean flg = false;
if (matcher.find())
{
flg = true;
}
return flg;

}
老紫竹 2009-07-13
  • 打赏
  • 举报
回复
匹配中文字符的正则表达式: [\u4e00-\u9fa5]

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧