public static List<Double> getNumbers(String s){
Pattern p = Pattern.compile("\\d+\\.?\\d*");
Matcher m = p.matcher(s);
List<Double> n = new ArrayList<>();
while(m.find()){
n.add(Double.valueOf(m.group()));
}
return n;
}
获取字符串中的数字
于 2024-01-10 15:17:35 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)