Skip to content

Instantly share code, notes, and snippets.

@zloydadka
Created October 16, 2011 16:29
Show Gist options
  • Save zloydadka/1291112 to your computer and use it in GitHub Desktop.
Save zloydadka/1291112 to your computer and use it in GitHub Desktop.
RegExp in VBA examples
Sub Test()
Const strTest As String = "qwerty123456uiops"
MsgBox RE6(strTest)
End Sub
Function RE6(strData As String) As String
Dim RE As Object, REMatches As Object
Set RE = CreateObject("vbscript.regexp")
With RE
.MultiLine = False
.Global = False
.IgnoreCase = True
.Pattern = "[0-9][0-9][0-9][0-9][0-9][0-9]"
End With
Set REMatches = RE.Execute(strData)
RE6 = REMatches(0)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment