See here:
Counting Lines in a String[
^] - it's to do with lines, but they are just a "special delimiter" (i.e. '\n') which you could replace with an array of "searchable characters".
It presents a variety of ways to do it, and tells you the probable performance cost of each.