67,513
社区成员
发帖
与我相关
我的任务
分享
String str = "<A href=\"http.baidu.com\">http://www.baidu.com</A>\r\n"
+ "<div href=\"http://www.google.com\">http://www.google.com</div>";
Pattern p=Pattern.compile("(?i)(http://[^\\<\\>]+)(?=\\</(\\w+)\\>)");
Matcher m=p.matcher(str);
StringBuffer sb=new StringBuffer();
while(m.find()){
System.out.println(m.start()+"->"+m.end());
m.appendReplacement(sb, "你想要的字符串");
}
m.appendTail(sb);
System.out.println(sb);