count number of occurrences in string c#
count number of occurrences in string c#
First use the following namesapce
Use the following Regx code to count
string source="one two three one two one"
int count = Regex.Matches(source, "\\b(" + Yourstring + ")\\b").Count;
that "\\b(" is used for eliminate specal charcter.
Comments
Post a Comment