正则提取字符串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); } } }
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

更多精彩