• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find particular characters within a String ?

 
kri shan
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find particular characters within a String ? indexOf() (or) contains() (or) any other optimized way ? Which is the best option ?
 
Daesung Park
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think indexOf() is enough.
 
kri shan
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i use indexOf(), can i find last occurrence of a character or a substring in the invoking string (or) can i use lastIndexOf() ?
 
Prashant Ladha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please look at regex.
 
Prashant Ladha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kri shan:
If i use indexOf(), can i find last occurrence of a character or a substring in the invoking string (or) can i use lastIndexOf() ?


yes, with lastIndexOf(String) you would get the last occurrence of that string.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic