I am trying to use the code below to apply this regex pattern that I have validated against my data on regex101.com. In Excel I always get #VALUE! error. I have tried variations on the code but always get the same error. If I use different regex patterns the code works fine. Any idea what in this pattern is causing a problem?
\d\w *+[A-Za-z]\w\d\d?+ *+\d++
Code (just an example - the code works with other patterns)
Function RegxFunc(strInput As String, regexPattern As String) As String
Dim regEx As New RegExp
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = regexPattern
End With
If regEx.Test(strInput) Then
Set matches = regEx.Execute(strInput)
RegxFunc = matches(0).Value
Else
RegxFunc = "not matched"
End If
End Function
\d\w *+[A-Za-z]\w\d\d?+ *+\d++
Code (just an example - the code works with other patterns)
Function RegxFunc(strInput As String, regexPattern As String) As String
Dim regEx As New RegExp
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = regexPattern
End With
If regEx.Test(strInput) Then
Set matches = regEx.Execute(strInput)
RegxFunc = matches(0).Value
Else
RegxFunc = "not matched"
End If
End Function