Fordraiders
asked on
vbscript and regex problem with pattern Extract just words from string
vbscript vba excel 2010
The following code pattern: works fine in vbscript editor checker:
http://www.regular-expressions.info/vbscriptexample.html
' MY STRING FOR TESTING
cd2 = """*F 3 120E R3*" apea NEAR"""
Dim result As String
Dim cd2 As String
Dim allMatches As Object
Dim RE As Object
Set RE = CreateObject("vbscript.reg exp")
' GIVE ME JUST THE WORDS EXCEPT FOR THE QUOTES
RE.Pattern = """\w+[A-Za-z]\s\w+[A-Za-z ]"""
RE.Global = True
RE.IgnoreCase = True
Set allMatches = RE.Execute(Cd)
If allMatches.Count <> 0 Then
result = allMatches.Item(0).SubMatc hes.Item(0 )
End If
cd2 = result
"result" should be "apea NEAR"
Thanks
fordraiders
The following code pattern: works fine in vbscript editor checker:
http://www.regular-expressions.info/vbscriptexample.html
' MY STRING FOR TESTING
cd2 = """*F 3 120E R3*" apea NEAR"""
Dim result As String
Dim cd2 As String
Dim allMatches As Object
Dim RE As Object
Set RE = CreateObject("vbscript.reg
' GIVE ME JUST THE WORDS EXCEPT FOR THE QUOTES
RE.Pattern = """\w+[A-Za-z]\s\w+[A-Za-z
RE.Global = True
RE.IgnoreCase = True
Set allMatches = RE.Execute(Cd)
If allMatches.Count <> 0 Then
result = allMatches.Item(0).SubMatc
End If
cd2 = result
"result" should be "apea NEAR"
Thanks
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Quite welcome.
ASKER