Answers for "java indexof nth occurrence"

0

java indexof nth occurrence

public static int ordinalIndexOf(String str, String substr, int n) {
    int pos = str.indexOf(substr);
    while (--n > 0 && pos != -1)
        pos = str.indexOf(substr, pos + 1);
    return pos;
}
Posted by: Guest on November-04-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language