可以使用正则表达式来提取出数字部分,示例代码如下:

String text = "/celebrity/1376035/";
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(text);
if (matcher.find()) {
    String number = matcher.group();
    System.out.println(number); // 输出 1376035
}
有一段文字 celebrity1376035使用java获取到1376035

原文地址: https://www.cveoy.top/t/topic/bJEQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录