Last active
January 11, 2018 06:51
-
-
Save KirillPashkov/eec89998dd58bb4f923c3f656c870bfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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