标签:str ati get 正则表达 pst bsp java tip add
/** * 正则提前字符串中的IP地址 * @param ipString * @return */ public static List<String> getIps(String ipString){ String regEx="((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"; List<String> ips = new ArrayList<String>(); Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(ipString); while (m.find()) { String result = m.group(); ips.add(result); } return ips; } public static void main(String[] args) { String ipString="!254.254.254.254 127.0.0.1localhost192.168.2.1localhost"; System.out.println(getIps(ipString)); }
标签:str ati get 正则表达 pst bsp java tip add
原文地址:https://www.cnblogs.com/xiehongwei/p/8931151.html