E
ExcelMonkey
My regex is not identifying multiple matches below. Why is this? I keep
getting a return of 1 instead of 3.
Sub Thing()
Dim x As String
Dim z As Double
x = "The black cat"
z = ReturnWords(x)
End Sub
Private Function ReturnWords(y As String) As Double
Dim objRegExp As Object
Dim Match As Variant
Dim Matches
Dim tempstring As Variant
Dim Counter As Double
Set objRegExp = CreateObject("Vbscript.RegExp")
objRegExp.IgnoreCase = IgnoreCase
objRegExp.MultiLine = MultiLine
objRegExp.Pattern = "\w+" 'words
Set Matches = objRegExp.Execute(y)
ReturnWords = Matches.Count
End Function
getting a return of 1 instead of 3.
Sub Thing()
Dim x As String
Dim z As Double
x = "The black cat"
z = ReturnWords(x)
End Sub
Private Function ReturnWords(y As String) As Double
Dim objRegExp As Object
Dim Match As Variant
Dim Matches
Dim tempstring As Variant
Dim Counter As Double
Set objRegExp = CreateObject("Vbscript.RegExp")
objRegExp.IgnoreCase = IgnoreCase
objRegExp.MultiLine = MultiLine
objRegExp.Pattern = "\w+" 'words
Set Matches = objRegExp.Execute(y)
ReturnWords = Matches.Count
End Function