asp 正则表达式使用方法

Function ValidateEmailAddr(strEmailAddr)
Dim re
Set re = new RegExp
re.IgnoreCase = false
re.global = false
re.pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"
ValidateEmailAddr=re.Test(strEmailAddr)
end function
'正则判断是否是合法的邮件地址
Function Z_chinaname(strNameAddr)
Dim chinaneme
Set chinaneme = new RegExp
chinaname.IgnoreCase = false
chinaname.global = false
chinaneme.pattern = "^[u4e00-u9fa5],{0,}$"
Z_chinaname=chinaneme.Test(strNameAddr)
end function
'正则判断联系人的名字必须为汉字
Function Z_tel(strtelAddr)
Dim ztel
Set ztel = new RegExp
ztel.IgnoreCase = false
ztel.global = false
ztel.pattern = "^((\d{3,4})|\d{3,4}-)?\d{7,8}$"
Z_tel=ztel.Test(strtelAddr)
end function
'正则判断联系电话的正误

'应用部分
if Z_tel(FixedPhone)=false then
response.Write"<script>alert('请输入正确的电话号码。');history.go(-1);</Script>"
response.End()
end if

if C_MSN<>"" then
if ValidateEmailAddr(C_MSN)=false then
response.Write"<script>alert('MSN地址错误。');history.go(-1);</Script>"
response.End()
end if
posted @ 2010-07-21 13:30  龙圆  阅读(291)  评论(0编辑  收藏  举报