正则提取字符串IP地址,返回IP列表
public class Main { public static void main(String args[]) { String str = "10.11.90.1 asedfa 1.1.1.1"; List list = new ArrayList(); Pattern pattern = Pattern.compile("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"); Matcher matcher = pattern.matcher(str ); while (matcher.find()) { String ip = matcher.group(0); list.add(ip); } } }