Java 用具有不同html但相同文本的匹配字符串替换字符串
第1条:Java 用具有不同html但相同文本的匹配字符串替换字符串,java,Java,第1条: <img alt="" src="http://abcghgds.com/justin-bieber-ferns-650-430.jpg" width="650" height="430" /> Have you seen <a href="http://www.abcdefg.com/between_two_ferns" target="_blank">Between Two Ferns</a>? 你忘了写数据,你所做的只是读取和操作数据 St
<img alt="" src="http://abcghgds.com/justin-bieber-ferns-650-430.jpg" width="650" height="430" /> Have you seen <a href="http://www.abcdefg.com/between_two_ferns" target="_blank">Between Two Ferns</a>?
你忘了写数据,你所做的只是读取和操作数据
String ans1= Jsoup.parse(string1).text();
String ans2 = Jsoup.parse(result1).text();
if(ans1.endsWith(ans2))
{
string1=string1.replace(result1, "");
}
Jsoup.parse(ans1).text(string1);
不,问题是结果1不会出现在string1中,因为两者都有不同的html,但有相同的文本。所以它不会被替换。你明白我的意思了吗?
String 1 = <img alt="" src="http://abcghgds.com/justin-bieber-ferns-650-430.jpg" width="650" height="430" />
String ans1= Jsoup.parse(string1).text();
String ans2 = Jsoup.parse(result1).text();
if(ans1.endsWith(ans2))
{
string1=string1.replace(result1, ""); ---> // This does not work as I have to replace the text as well as the html from the original string to get the desired op. How do I do it?
}
String ans1= Jsoup.parse(string1).text();
String ans2 = Jsoup.parse(result1).text();
if(ans1.endsWith(ans2))
{
string1=string1.replace(result1, "");
}
Jsoup.parse(ans1).text(string1);