📜  java regex ip - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:44.405000             🧑  作者: Mango

代码示例2
public static boolean isIP(String ip)  {
    Pattern p = Pattern.compile("(([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.){3}([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])");
    Matcher m = p.matcher(ip);
    return m.matches();
}