智能获取IP范围方法新增常用范围符号~ 192.168.0.1~192.168.0.5

This commit is contained in:
田金成 2025-03-26 19:08:56 +08:00
parent 7f4ed213ac
commit 8adbf36a35

View File

@ -31,6 +31,11 @@ public class Ipv4Util {
*/
public static final String IP_SPLIT_MARK = "-";
/**
* IP段的分割符
*/
public static final String IP_SPLIT_TILDE = "~";
/**
* IP与掩码的分割符
*/
@ -60,6 +65,7 @@ public class Ipv4Util {
* @return IP集
*/
public static List<String> list(String ipRange, boolean isAll) {
ipRange = ipRange.replaceAll(IP_SPLIT_TILDE,IP_SPLIT_MARK);
if (ipRange.contains(IP_SPLIT_MARK)) {
// X.X.X.X-X.X.X.X
final String[] range = StrUtil.splitToArray(ipRange, IP_SPLIT_MARK);