Find the index of the Nth occurrence of a character in a string
<p>I've found <code>index</code> and <code>rindex</code> for finding the first or last occurrence of a character (or substring) in a string. I'm also aware that they have an <code>offset</code> that can be used to start at a certain index.</p>

<p>What I want to know is if there is a simple way to find the index of the Nth occurrence of a character or substring in a string. I'd prefer not to have to do it with a regex and would rather not to have to write a loop that just repeatedly calls <code>index</code> with an offset.</p>

<p>EDIT: I didn't state the restriction well. The reason I said "no loop" is I am looking for a built-in way to do it, which exists in many languages.</p>