且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何验证URL?

更新时间:2022-01-10 22:51:47

#\ =〜])* [^ \.\,\)\(\ s]
#\=~])*[^\.\,\)\(\s]


" ; Regex reg = Regex(样式,RegexOptions.Compiled | RegexOptions.IgnoreCase); 返回 reg.IsMatch(url); }
"; Regex reg = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); return reg.IsMatch(url); }

 

private void comboBox_Url_Validating(object sender, CancelEventArgs e)
       {
           bool s = isValidUrl(comboBox_Url.Text);
           if (s)
           {
               MessageBox.Show("URL is valid.");
              
           }
           else
           {
               MessageBox.Show("In valid URL.");
               this.comboBox_Url.Focus();
           }


这里是通用表达式
Here is the general expression
^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\''\/\\\+&%\