I need to change a piece of code which includes this:
string.indexOf(\"bc\")
How can this be changed by a solution that skips the occurrenc
Use regex to find the String that matches your criteria, and then find the index of that String.
int index = -1;
Pattern p = Pattern.compile("[^Aa]?bc");
Matcher m = p.matcher(string);
if (m.find()) {
index = m.start();
}
Something like this. Where 'string' is the text you're searching and 'index' holds the location of the string that is found. (index will be -1 if not found.) Also note that the pattern is case sensitive unless you set a flag.