网络编程
位置:首页>> 网络编程>> Asp编程>> ASP正则表达式验证域名是否合法

ASP正则表达式验证域名是否合法

 来源:asp之家 发布时间:2010-01-02 20:44:00 

标签:正则表达式,验证,域名

大家在使用ASP设计用户提交表单的时候,如果涉及到网址输入框,那么相信都有可能会用到这个效果,使用正则表达式验证网址合法性。

代码如下:

<%
Function iswww(strng)
iswww = false
Dim regEx, Match
Set regEx = New RegExp
regEx.Pattern = "^\w+((-\w+)|(\.\w+))*[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$" 
regEx.IgnoreCase = True
Set Match = regEx.Execute(strng)
if match.count then iswww = true
End Function
'调用方法:
Response.Write iswww("aspxhome.com")
%>

 函数返回值:false或true

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com