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("somebody@domain.co.uk") = True
Response.Write EmailValidator.Test("someone@domain.com") = True
Response.Write EmailValidator.Test("some.body@domain.co.uk") = True
Response.Write EmailValidator.Test("broken@domain..co.uk") = 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("name@domain.abcde") = False
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…