wood burning stoves*
The moose likes Beginning Java and the fly likes String question! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String question!" Watch "String question!" New topic
Author

String question!

zoster gibrilian
Greenhorn

Joined: Sep 17, 2003
Posts: 7
How can I find an occurrence of the first string in the second one?
Example: How can I find the first occurrence of the string �Post New Topic� in the source code of this page?
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
I am not sure if i understand your example, but two check the occurence of one string in another you can use indexOf method.
here is what the API says:
Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that: this.startsWith(str, k) is true.

HTH


The secret to creativity is knowing how to hide your sources.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by zoster gibrilian:
How can I find an occurrence of the first string in the second one?
Example: How can I find the first occurrence of the string �Post New Topic� in the source code of this page?

try the String method ( jdk 1.4 ) - indexOf( String )
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String question!