Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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