is string provide any function that allow to calculate there is how many substring inside a string??
example: string str = "how are you?"
is it possible to tell how many "o" inside the str?
Printable View
is string provide any function that allow to calculate there is how many substring inside a string??
example: string str = "how are you?"
is it possible to tell how many "o" inside the str?
Use the substring() command with a variable. when you find the string, move the variable past it, and then LOOP until you don't find it again.
that's actually pseudo-code that will solve the problem
Another way would be to use Regular expressions.Code:string str = "how are you?";
System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("o");
int i = rx.Matches(str).Count;
Excellent.Quote:
Originally Posted by Shuja Ali
Thank you very much....Quote:
Originally Posted by Shuja Ali