正則表達式驗證IP輸入

string regexString="((2[0-4]//d|25[0-5]|[01]?//d//d?)//.){3}(2[0-4]//d|25[0-5]|[01]?//d//d?)";
 Regex regex=new Regex(regexString);

//this.txtIP.Text  is user input value
if (!regex.Match(this.txtIP.Text).Success)
{
                b = false;
                MessageBox.Show("IP Address Format is Incorrect");
                this.txtIP.EditValue = "";
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章