Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String question!

 
zoster gibrilian
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic