onekidney onekidney - 1 year ago 95
C# Question

Count the number of times a string appears within a string

I simply have a string that looks something like this:


All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is something like String.CountAllTheTimesThisStringAppearsInThatString() but for some reason I just can't figure it out. Help?

Answer Source
Regex.Matches(Regex.Escape(input),  "true").Count
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download