How to return the next indexOf after a previous?

indexof, java, string

Solution

Try this :

 String word = "(a+b)*(c+d)*(e+f)";
 String c = "(";
  for (int index = word.indexOf(c);index >= 0; index = word.indexOf(c, index + 1)) {
       System.out.println(index);//////here you will get all the index of  "("
    }

Problem

For example: ``` str = "(a+b)*(c+d)*(e+f)" str.indexOf("(") = 0 str.lastIndexOf("(") = 12 ``` How to get the index in second bracket? (c+d) <- this

Original source