• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to count spl characters from string

 
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!