1.在前端(SWT)表单页面,经常会使用验证,非空的验证,太简单,代码不贴了。验证只能是字母(不区分大小写)、数字、汉字的正则表达式以及验证的代码如下:
private boolean valiOrganName(){
String organName="test";
//包含数字、字母(不区分大小写)、汉字的正则表达式,这里还限制了长度1~16
String regex="^[\u4E00-\u9FA5\uF900-\uFA2D\w]{1,16}$";
return matches(regex, organName);
}
/**
*
* @Title: matches
* @Description: 验证inputValue是否符合正则表达式regex,符合返回true,不符合返回false
* @param regex
* @param inputValue
* @return boolean
*/
public boolean matches(String regex, String inputValue) {
Pattern pattern = Pattern.compile(regex);
return pattern.matcher(inputValue).matches();
}
最后
以上就是体贴小蝴蝶最近收集整理的关于常用验证只能是字母(不区分大小写)、数字、汉字的正则表达式的全部内容,更多相关常用验证只能是字母(不区分大小写)、数字、汉字内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复