标签:blog java sp for div log bs as tt
public static boolean checkChinese(String sequence) { final String format = "[\\u4E00-\\u9FA5\\uF900-\\uFA2D]"; boolean result = false; Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(sequence); result = matcher.find(); return result; }
public static boolean checkNickname(String sequence) { final String format = "[^\\u4E00-\\u9FA5\\uF900-\\uFA2D\\w-_]"; Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(sequence); return !matcher.find(); }
检测字符串中是否包含汉字;检测字符串中只能包含:中文、数字、下划线(_)、横线(-)
标签:blog java sp for div log bs as tt
原文地址:http://www.cnblogs.com/penger/p/4082546.html