📜  ip地址模式正则表达式javascript代码示例

📅  最后修改于: 2022-03-11 15:02:20.656000             🧑  作者: Mango

代码示例1
ValidateIPaddress(prompt("Enter IP Address"));
function ValidateIPaddress(ipaddress) 
{
 if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress))
  {
      alert("The IP Address I Valid")
  }
alert("You have entered an invalid IP address!")
}