Since the top answer here is in VB6 I thought I'd add one here in VBScript (since that's what the question is asking for):-
Option Explicit
Function GetEmailValidator()
Set GetEmailValidator = New RegExp
GetEmailValidator.Pattern = "^((?:[A-Z0-9_%+-]+.?)+)@((?:[A-Z0-9-]+.)+[A-Z]{2,4})$"
GetEmailValidator.IgnoreCase = True
End Function
Dim EmailValidator : Set EmailValidator = GetEmailValidator()
Now some tests:-
Response.Write EmailValidator.Test("") = False
Response.Write EmailValidator.Test(" ") = False
Response.Write EmailValidator.Test("[email protected]") = True
Response.Write EmailValidator.Test("[email protected]") = True
Response.Write EmailValidator.Test("[email protected]") = True
Response.Write EmailValidator.Test("[email protected]") = False
Response.Write EmailValidator.Test("@oops.co.uk") = False
Response.Write EmailValidator.Test("name") = False
Response.Write EmailValidator.Test("name@uk") = False
Response.Write EmailValidator.Test("name@uk") = False
Response.Write EmailValidator.Test("[email protected]") = False
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…