Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Regex Multiple Match not working
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Regex Multiple Match not working
On Tue, 12 May 2009 11:46:01 -0700, ExcelMonkey
wrote: 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 You probably need to set the Global property of the object to true: objRegExp.Global = TRUE. --ron |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Regex Multiple Match not working
Yup that worked. Why?
Thanks EM "Ron Rosenfeld" wrote: On Tue, 12 May 2009 11:46:01 -0700, ExcelMonkey wrote: 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 You probably need to set the Global property of the object to true: objRegExp.Global = TRUE. --ron |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Regex Multiple Match not working
On Tue, 12 May 2009 13:42:13 -0700, ExcelMonkey
wrote: Yup that worked. Why? Thanks EM Look he http://support.microsoft.com/default...02&Product=vbb --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Match formula to match values in multiple columns | Excel Discussion (Misc queries) | |||
MATCH working but not.... | Excel Worksheet Functions | |||
MATCH Multiple Criteria & Return Previous / Penultimate Match | Excel Worksheet Functions | |||
MATCH not working | Excel Worksheet Functions |