-
[RESOLVED] RegEx in VBA
Code:
Dim RegEx As Object
Dim valid As String
Set RegEx = CreateObject("vbscript.regexp")
RegEx.Pattern = " \d{10}"
valid = RegEx.Replace("this is a test 1234567895 for real", "")
MsgBox (valid)
This work fine .. only problem is that i dont need to strip the 10 digits, but i need that value of 10 digits.. With what command should i replace 'Replace' with?
valid is now: "this is a test for real"
i need: value = "1234567895"
-
Re: RegEx in VBA
nm
Code:
Dim RegEx As Object
Dim RegMatches As Object
Set RegEx = CreateObject("vbscript.regexp")
With RegEx
.MultiLine = False
.Global = False
.IgnoreCase = True
.Pattern = " \d{10}"
End With
Set RegMatches = RegEx.Execute("this is a test 1234567895 for real")
MsgBox (RegMatches(0))