Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to extract a numeric substring from a string. Here's the code
that I have: Const patternNetTerms = "^.*?(\d+).*?$" Dim regEx Dim matches Dim match Set regEx = New RegExp 'Set regEx = CreateObject("vbscript.regexp") regEx.Pattern = patternNetTerms regEx.IgnoreCase = False regEx.Global = True regEx.MultiLine = False Set matches = regEx.Execute(sNetTerms) If matches.Count = 1 Then MsgBox "# of matches: " & matches.Count For Each match In matches MsgBox "Match: " & match.value Next End If When the string is "Net 10 Days", the only output I'm getting is the entire string. How do I retrieve the "10"? According to the regex calculator at http://www.codehouse.com/webmaster_tools/regex/, my expression does works. So, my problem appears to be in how I'm trying to retrieve the matches. Anyone have any suggestions as to what I'm doing wrong? TIA, Richard |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Another Problem with Regex Pattern | Excel Programming | |||
Help with a Regex Pattern | Excel Programming | |||
Regex Capture problem | Excel Programming | |||
RegEx to parse something like this... | Excel Programming | |||
Regex Question | Excel Programming |