String1:
<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>?
Result1:
Have you seen <a style = "display:inline" href="http://www.abcdefg.com/between_two_ferns" target="_blank">Between Two Ferns</a>?
I'm trying to check if the text is string1 ends with the text in result1. If it does then I want to replace the text(which is same as text in result1) in String1 with ""
So basically in the above case the expected output would be:(As text in string1 ends with the text in result1) I want this output
String 1 = <img alt="" src="http://abcghgds.com/justin-bieber-ferns-650-430.jpg" width="650" height="430" />
Though the text is same, the associated html it is wrapped into is different. So I can't really replace it .
Here's what I tried
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?
}