程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程問題解答 >> 如何判斷URL格式是否符合規范?

如何判斷URL格式是否符合規范?

編輯:編程問題解答
<%
 function checkisUrl(tmpString)

      dim c,i
      checkisUrl = true
      tmpString=Lcase(trim(tmpString))
      if left(tmpString,7)<>"http://" then tmpString="http://"&tmpString
      for i = 8 to Len(checkisUrl)
            c = Lcase(Mid(tmpString, i, 1))
            if InStr("abcdefghijklmnopqrstuvwxyz_-./\", c) <= 0 and not IsNumeric(c) then
                  checkisUrl = false
                  exit function
            end if
      next
      if Left(tmpString, 1) = "." or Right(tmpString, 1) = "." then
            checkisUrl = false
            exit function
      end if
      if InStr(tmpString, ".") <= 0 then
            checkisUrl = false
            response.Write "f3"
            exit function
      end if
      if InStr(checkisUrl, "..") > 0 then
            checkisUrl = false
      end if

end function
%>
<%

if checkisUrl(request("u"))=true then
      %>恭喜,你的URL通過!
<%
else
      %>對不起,你的URL不合乎規范,請重新檢查!
<%end if%>

[1]

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved