这里举一个例子去掉 z参数
public static String removeZ(String encode) {
String encode = "<a href=\"http://baidu.com/?&z=vQffSQV(BA560\">连接地址</a><br/><a href=\"http://wapttw.cn/&z=vQffSQV(BA560\">天天wap</a><br/><a href=\"http://tx.com.wapmini.cn/&z=vQffSQV(BA560\">迷你WAP</a><br/><a href=\"http://tx.com.cn/&z=vQffSQV(BA560\">天下测试</a><br/>";
String regex = "<a href=['\"]?http:[/\\\\]{2}(?!((baidu\\.com)|(baidu\\.cn)|(baidu\\.com\\.cn)|(club\\.baidu\\.com\\.cn))).*?>";
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(encode);
StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement(sb, m.group().replaceAll("[zZ]=[0-9a-zA-Z)(_]+", ""));
}
m.appendTail(sb);
System.out.println(sb.toString());
}
对于URL连接删除一个参数
猜你喜欢
转载自mainer5211107.iteye.com/blog/1659344
今日推荐
周排行