Hi Matt,
Here is a simple way to do it, just setting the pattern as the match string.
Function strCount(theStr, subStr)
Set re = New RegExp
re.Pattern = subStr
re.Global = True
Set oMatches = re.Execute(theStr)
strCount = oMatches.Count
End Function
The Execute method will create a collection of matched strings, and the Count property tells you how many were found.
You have to be careful with using regular expressions, as if you are looking for substrings with non-letter characters in, such as * or (), they would be used as special pattern matching constructs within the regexp, and so you would probably get the wrong results back. You could get possibly get round this by escaping these characters by adding \ before them, but that obviously requires another regexp and more work.
On another note, the simple text matching used in the Split function is generally quicker than that used by regular expressions, as it is just matching characters rather than patterns. You could build a hybrid function which uses the Split method if theStr is less than, say, 50 characters, and regular expressions if longer.
HTH
Phil