Doubt with String

Hi, how can I get the index of the n occurrence of a String inside a string

(i. e.) I have the string

"<td>xxx</td><td>yyy</td><td>zzz</td>"

I want to know the index of the second or first of third or any occurrence of "<td>"

I've seen IndexOf, but it only returns the first occurrence.

[386 byte] By [Chidoa] at [2007-11-26 18:02:42]
# 1
There's also an indexOf that takes a starting point from which to search.
jverda at 2007-7-9 5:32:41 > top of Java-index,Java Essentials,Java Programming...
# 2

String str = "<td>xxx</td><td>yyy</td><td>zzz</td>";

String td = "<td>";

int first = str.indexOf(td);

int second = str.indexOf(td, first + 1);

int third = str.indexOf(td, second + 1);

duckbilla at 2007-7-9 5:32:42 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks, So now I understand that I have to write code because there isn't a method inside class String that gives to me the index of the n ocurrence of a string inside another.Am I right?
Chidoa at 2007-7-9 5:32:42 > top of Java-index,Java Essentials,Java Programming...
# 4
Oh, I misread the question.Well, you can still use the indexOf(String str, int fromIndex), applied repeatedly until you get to where you're looking for. Or you might be able to cook up a regex.
jverda at 2007-7-9 5:32:42 > top of Java-index,Java Essentials,Java Programming...