如何找到String字符串中所有的数字

走着路睡觉
  • java
小于 1 分钟

Pattern p = Pattern.compile("-?\\d+");
Matcher m = p.matcher("There are more than -2 and less than 12 numbers here");
while (m.find()) {
  System.out.println(m.group());
}
上次编辑于:
贡献者: zhaojingbo
Loading...