public static List<Integer> getNumbers(String content) {
List<Integer> results = new ArrayList<>();
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
results.add(Integer.valueOf(matcher.group(0)));
}
return results;
}
获取String中的所有数字并转化为int类型
最新推荐文章于 2023-11-04 15:46:46 发布