本文介绍了在VBScript普通防爆pressions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
VBScript中是否有正则表达式本机实现?我需要在一个旧的ASP应用程序验证电子邮件地址。
Does VbScript have a native implementation for Regex? I need to validate e-mail addresses on an old ASP application.
任何指针将是巨大的。
推荐答案
这例子是AlexCuse从<一个href=\"http://wiki.lessthandot.com/index.php/Using_Regular_Ex$p$pssions_For_Pattern_Matching_in_Access\"相对=nofollow> LessThanDot
This example is by AlexCuse from LessThanDot
Function ValidEmail(ByVal emailAddress)
'this function will use regular expressions to check an '
'email address for validity '
'instantiate regex object container, output boolean '
Dim objRegEx, retVal
'using late binding, vbscript reference is not required '
Set objRegEx = CreateObject("VBScript.RegExp")
'.pattern -looks for a valid email address '
With objRegEx
.Pattern = "^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$"
.IgnoreCase = True
End With
retVal = objRegEx.Test(emailAddress)
'get rid of RegEx object '
Set objRegEx = Nothing
ValidEmail = retVal
End Function
这篇关于在VBScript普通防爆pressions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!