Skip to content

Instantly share code, notes, and snippets.

@KirillPashkov
Last active January 11, 2018 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KirillPashkov/eec89998dd58bb4f923c3f656c870bfd to your computer and use it in GitHub Desktop.
Save KirillPashkov/eec89998dd58bb4f923c3f656c870bfd to your computer and use it in GitHub Desktop.
Function MatchRegex(RegexPattern,InputString)
If _
IsNull(RegexPattern) Or IsEmpty(RegexPattern) Or _
IsNull(InputString) Or IsEmpty(InputString) _
Then
MatchRegex = False
Else
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = RegexPattern
Set colMatches = objRegEx.Execute(InputString)
If colMatches.Count = 1 Then
MatchRegex = True
Else
MatchRegex = False
End If
End If
End Function
MatchRegex("^[0-9]{4}$","1234")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment