I have a string that is the complete content of an html page and I am trying to find the index of 2nd occurence of . Does anyone have any suggesti
First find the first index, then look for the second index starting your search from the first index +1
String string = "firstsecond";
int firstIndex = string.indexOf("");
int secondIndex = string.indexOf("", firstIndex+1);
System.out.println("second index: " + secondIndex);
This is some pretty basic code btw, you will want to build some additional checks (index != -1 and the like) Also in your post title it said nth occurence but in your post you mention the second occurence specifically. I'm sure you'll be able to figure it out from here if you actually need the nth occurence though.