0
点赞
收藏
分享

微信扫一扫

IPv4正则表达式

juneyale 2022-08-18 阅读 4

apache common-httpclient-4.5.2.jar

package org.apache.http.conn.util;

public class InetAddressUtils {

private InetAddressUtils() {
}

private static final String IPV4_BASIC_PATTERN_STRING =
"(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}" + // initial first field, 1-255
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}" + // following 2 fields, 0-255 followed by .
"([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; // final field, 0-255

private static final Pattern IPV4_PATTERN =
Pattern.compile("^" + IPV4_BASIC_PATTERN_STRING + "$");
}

 

举报

相关推荐

0 条评论