Regex r = new Regex(@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"); if (r.IsMatch(cond.NodeIp)) { model.Message = "输入的IP正确的!"; return View(model); } else { model.Message = "输入的IP错误的!"; return View(model); }
这个正则自己写的验证过有用。找不到的可以贴上去试试
时间: 2024-10-22 12:27:35