Regular Expression to validate Email address
Pass a string as a parameter to the below procedure to check whether the string is a valid email id or not.
Public Function blnEmailValid(ByVal strEmailAdd As String) As Boolean With CreateObject("VBScript.RegExp") .IgnoreCase = True .Global = True .Pattern = "^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$" blnEmailValid = .Test(strEmailAdd) End With End Function Sub Test() MsgBox blnEmailValid("abc@EE.com") End Sub
»
- Vishesh's blog
- Login or register to post comments
- 23713 reads
Validate PolicyDivision
Good morning. I was wondering if anyone knows how to set up a Regex (in VBA) to test for a valid PolicyDivision string. I have the follwoing so far:
Public Function ValidPolDiv(ByVal strPolDiv As String) As Boolean
With CreateObject("VBScript.RegExp")
.IgnoreCase = True
.Global = True
.Pattern = "^([0-9][0-9][0-9][0-9][0-9][0-9]\-\[0-9][0-9][0-9][0-9])$"
ValidPolDiv = .Test(strPolDiv)
End With
End Function
I am new to RegEx and this is not working. Thank you, WHEELS