Created
January 4, 2016 08:32
-
-
Save Limuyang1013/3bb5f94d65607cd68a16 to your computer and use it in GitHub Desktop.
检测字符串中只能包含:中文、数字、下划线(_)、横线(-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment