Pattern p = Pattern.compile("\\(\\'[\\w | / | : | . | ? | & | _ | % | = ]*\\'\\)");
        Matcher m = p.matcher("<script>location.replace('https://login.10086.cn/AddUID.action?channelID=00791&backl%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 判断 把所有的卡头中间,所有的情况都写进入
个人感觉正则表达式写的好不好,完全在于对匹配的内容的认识是否全面。
    秦水坡-杜撰
 
                    
                     
                    
                 
                    
                 

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号