------ Solution ---------------------------------- ----------
see your label whether a canonical form , and if you do not consider the space ( for example, does not appear xxx ), can do:
String[] href = {
"go<a href=u.php?action=show&uid=122113 target=_blank>超链接文本</a>od",
"go<a href=u.php?action=show&uid=122113 target=_blank>超链接文本</a>od<a href></a>",
};
for (String h : href) {
System.out.println(h.replaceAll("<a[^>]+>[^<]*</a>", ""));
}
------ Solution ------------------------------------- -------
In fact, you can give an example of a little more appropriate . .
html.repaceAll ("? s)
------ Solution ------- -------------------------------------
replaceAll ("
------ For reference only ---------------------- -----------------
static void func4()
{
String str="one <a href=u.php?action=show&uid=122113 target=_blank>超链接文本</a> two <a> adfadf </a> Three";
System.out.println("before:-----------------\n"+str);
String regex="<\\s*a.*?/a\\s*>";
str=str.replaceAll(regex, "");
System.out.println("after:-----------------\n"+str);
}
没有评论:
发表评论