导航

判断一个字符串是不是一个网址

Posted on 2011-03-28 14:47  yjss  阅读(2061)  评论(0编辑  收藏  举报
        public static bool IsUrl(string url)
        {
            return Regex.IsMatch(url, @"^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)?$",
                        RegexOptions.IgnoreCase);
        }