87,997
社区成员




public class Test {
public static void main(String[] args){
String A="a";
String str="abcdefg";
String str1="<div>"+str+"</div>;";
Pattern p=Pattern.compile("<div[^>]*>(.[^>]*)</div>");
Matcher m=p.matcher(str1);
if(m.find())
System.out.println(str1.replace(m.group(1), m.group(1).replaceAll(A,"<strong>a</strong>")));
}
}
str是你以前的<div>。。。的字符串
str=str.replaceAll("</?div[^>]*>","");
String newStr=str.replace(str,"<strong>'"+A+"'</strong>");
str.replaceAll("</?div[^>]*>","");
String div = "<div class=\"out\" onclick=\"\">abcde</div>";
Pattern p = Pattern.compile("(<div .*?>)(.*)(</div>)");
Matcher m = p.matcher(div);
if(m.find()){
System.out.println(m.group(2));
}