Say, I have a String:
String someString = "<html><body><div><div><div class="unknown"><b>Content</b></div></div></div></body></html>";
In this String the position of the "Content" is known.
Now, I want to turn the most inner divs into span tags. So what I want to do:
someString.replacePreviousOccurrence(someString.indexOf("Content"), "<div ", "<span>");
someString.replaceNextOccurrence(someString.indexOf("Content"), "</div>", "</span>");
Is there something in Java to do this? Or just to get the index of a previous and next occurrence of a substring from a specified index?
Edit: forgot to specify the divs have unknown tags (may have classes and stuff) and there may be stuff in between (like the tag in the example).