Beispiel #1
0
 // Fetch the HTML Title from remote page
 public void GetTitle()
 {
     // Check Prefix
     System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
     if (cmpUrl.IsPrefix(this.tb_LinkUrl.Text, "http") == false)
     {
         this.tb_LinkUrl.Text = "http://" + this.tb_LinkUrl.Text;
     }
 }
Beispiel #2
0
        public static bool IsValidUrl(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(false);
            }
            System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
            if (cmpUrl.IsPrefix(url, "http://") == false && cmpUrl.IsPrefix(url, "https://") == false)
            {
                url = "http://" + url;
            }

            //Regex urlRegex = new Regex("(^|[^\\w'\"]|\\G)(?<uri>(?:https?|ftp)&#58;&#47;&#47;(?:[^./\\s'\"<)\\]]+\\.)+[^./\\s'\"<)\\]]+(?:&#47;.*?)?)(\\.[\\s<'\"]|[\\s,<'\"]|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase); // Regex("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(/?([^#]*))?(#(.*))?");
            //^((https?|ftp)://|(www|ftp)\.)[a-z0-9-]+(\.[a-z0-9-]+)+([/?].*)?$
            Regex urlRegex = new Regex("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(/?([^#]*))?(#(.*))?");

            return(urlRegex.IsMatch(url));
        }
Beispiel #3
0
        public static bool IsValidUrl(string url)
        {
            bool bResponse = false;

            System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
            if (cmpUrl.IsPrefix(url, @"http://", System.Globalization.CompareOptions.IgnoreCase) == false)
            {
                url = @"http://" + url;
            }
            Regex RgxUrl = new Regex(@"^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (RgxUrl.IsMatch(url))
            {
                bResponse = true;
            }
            else
            {
                bResponse = false;
            }
            return(bResponse);
        }