验证字符串格式只能为汉字字母数字

String content = “testContent”;
String regex="^[a-zA-Z0-9\u4E00-\u9FA5]+$";
Pattern pattern = Pattern.compile(regex);
Matcher match=pattern.matcher(content);
boolean b=match.matches();
if(b)
{
Toast.makeText(this, "success...", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "fail...", Toast.LENGTH_SHORT).show();
}

posted @ 2018-01-23 10:28  Waves-a  阅读(513)  评论(0编辑  收藏  举报