标签:内容 java正则表达式 location 中间 tps demo java add cti
Pattern p = Pattern.compile("\\(\\‘[\\w | / | : | . | ? | & | _ | % | = ]*\\‘\\)");
Matcher m = p.matcher("<script>location.replace(‘https://login.10086.cn/AddUID.action?channelID=00791&backUrl=http%3A%2F%2Fservice.jx.10086.cn%3A80%2Fservice%2FbackAction.action%3Fmenuid%3D000200010003%26SAMLart%3D021c3b40cac0451da521b81e1f4a27d0_15279252432%26RelayState%3Dtype%3DA%3Bbackurl%3Dhttp%3A%2F%2Fservice.jx.10086.cn%3A80%2Fservice%2FbackAction.action%3Fmenuid%3D000200010003%3Bnl%3D6%26isEncodePassword%3D1%26displayPic%3D1%26displayPics%3Dnull%26isEncodeMobile%3D1&Artifact=2a47789396a74882b70ac2ea9b06e1f4&TransactionID=942153683‘);</script>");
// Matcher m = p.matcher("<script>location.replace(‘sdfdsf/:.?‘)");
System.out.println(m.groupCount());
if(m.find()){
System.out.println(m.group(0));
}else{
System.out.println("no");
}
\\( 表示转译 (
其实正则表达式其实就相当于写if else 判断 把所有的卡头中间,所有的情况都写进入
个人感觉正则表达式写的好不好,完全在于对匹配的内容的认识是否全面。
标签:内容 java正则表达式 location 中间 tps demo java add cti
原文地址:http://www.cnblogs.com/qinshuipo/p/6868132.html