1.java开发中java
Pattern pattern = Pattern.compile(String regex, int flags);//regex是正则表达式,flags是解析模式 // Pattern.CANON_EQ 启用规范等价;Pattern.CASE_INSENSITIVE 启用不区分大小写的匹配;Pattern.COMMENTS 模式中容许空白和注释;Pattern.DOTALL 启用 dotall 模式; // Pattern.LITERAL 启用模式的字面值分析;Pattern.MULTILINE 启用多行模式;Pattern.UNICODE_CASE 启用 Unicode 感知的大小写折叠;Pattern.UNIX_LINES启用 Unix 行模式; Matcher matcher = pattern.matcher(string);//输入须要解析的字符串 Boolean aBoolean = matcher.matches();//解析结果 //或者 String string = "112233"; Boolean bool = string.matches("^[0-9]*");
2.js语句中git
/*校验是否中文名称组成 */ function ischina(value) { return /^[\u4E00-\u9FA5]{2,4}$/.test(value); } //或者 function ischina(value) { console.log(value.match(/<[^>]+>/g)); } //js其余语法 var isTrue = "Hello peppa".search("peppa"); var string = "Hello peppa".replace("peppa","jorge");
3.Spring EL语句中正则表达式
@Value("#{'100' matches '\\d+' }") private boolean isDigit;