indexOfNth

fun String.indexOfNth(substring: String, n: Int): Int

Returns the index of the nth non-overlapping occurrence of substring, where n counts from 1, or -1 when there are fewer than n occurrences.

Returns -1 when substring is empty or n is less than 1.