Let\'s say we have something like:
&firstString=someText&endString=OtherText
And I would like to replace \"someText\" with somethin
This solution checks that we're not going of the end of the string and will do it for multiple occurrences.
int startIndex = text.indexOf(startDelim);
while (startIndex > -1)
{
int endIndex = text.indexOf(endDelim, startIndex);
String endPart = "";
if ((endIndex + endDelim.length()) < text.length())
endPart = text.substring(endIndex + endDelim.length());
text = text.substring(0, startIndex) + replacementText + endPart;
startIndex = text.indexOf(startDelim);
}