300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > JAVA正则表达式验证英文字母 汉字和数字!!!

JAVA正则表达式验证英文字母 汉字和数字!!!

时间:2019-05-10 03:26:44

相关推荐

JAVA正则表达式验证英文字母 汉字和数字!!!

java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字

public static boolean isLetterDigitOrChinese(String str) {String regex = "^[a-z0-9A-Z\u4e00-\u9fa5]+$";return str.matches(regex);}

java代码输入框验证(本公司封装框架)

/*** 代码集名称和描述校验*/@PageEvent("specialValue")@NoRequiredValidatepublic void specialValue() throws Exception {String t2Value = this.getPageElement("t2").getValue();String area2Value = this.getPageElement("area2").getValue();if (t2Value != null && !"".equals(t2Value)) {String regex = "^[A-Za-z0-9\u4e00-\u9fa5]+$";if (t2Value.matches(regex)) {this.getPageElement("t2").setValue(t2Value);} else {this.setMainMessage("代码集名称只能输入汉字、字母或阿拉伯数字");this.getPageElement("t2").setValue("");}}if (area2Value != null && !"".equals(area2Value)) {String regex = "^[A-Za-z0-9\u4e00-\u9fa5]+$";if (area2Value.matches(regex)) {this.getPageElement("area2").setValue(area2Value);} else {this.setMainMessage("代码集名称只能输入汉字、字母或阿拉伯数字");this.getPageElement("area2").setValue("");}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。