WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Strings

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Count Number of Instances of a Character in a String

Keywords: 	   strcount

Question:

Does Winbatch have a string function, like StrCount, that counts the number of occurrences of a character in a string?

Answer:

;Find number of "a"'s in the string
string="abcannannndnnnannnwennnannannaaannndndnnd"
count=Strlen(string) - StrLen(StrReplace(string,"a",""))
Message("Count",count)

Article ID:   W14502
Filename:   Number of Instances of Char in a String.txt
File Created: 2000:03:30:11:43:44
Last Updated: 2000:03:30:11:43:44