This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to count spl characters from string  RSS feed

 
Sham Jowsaki
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I hv an string which i need to find how many *,@ is available.
Eg.
get *duke *pwd +8888 -text
help * duke * pwd +8888 * %text
The input string is different format like above.
Pls advise me.
Thanks
Jowsaki
 
Ian Montgomery
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jowsaki,
You could use the String class' indexOf() method.
final String AT = "@";
while ( yourString.indexOf(AT) != -1 )
count++;
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html#indexOf
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!