(String str)
| 69 | } |
| 70 | // ip地址匹配 |
| 71 | public static String IP(String str){ |
| 72 | ArrayList<String> ip = new ArrayList<>(); |
| 73 | // String is_ip = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; |
| 74 | String is_ip = "\\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0]|[1-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; |
| 75 | Matcher matcher = Pattern.compile(is_ip).matcher(str); |
| 76 | while (matcher.find()){ |
| 77 | ip.add(matcher.group()); |
| 78 | } |
| 79 | // 去重 |
| 80 | List<String> ip_rd = Re.removeDuplicate(ip); |
| 81 | return StringUtils.strip(ip_rd.toString(),"[]"); |
| 82 | } |
| 83 | // 内网ip匹配 |
| 84 | public static boolean in_ip(String str){ |
| 85 | String in_ip = "\\b(?:(10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))|(?:172\\.(?:(?:1[6-9])|(?:2\\d)|(?:3[01]))\\.\\d{1,3}\\.\\d{1,3})|(?:192\\.168\\.\\d{1,3}\\.\\d{1,3})"; |
no test coverage detected