java截取出字符串中的所有组数字

取出一个字符串中的所有数字并不难,但是怎么分组取出这些数字呢?比如:123和234以及1255,这样一个字符串,需要取出来的结果为 : 123、234、1255,而不是取出单个数字或取出的结果集为全部数据。

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());
}

  如上代码,打印结果为 -2和12两个结果。