如何获取字符串中的整数(扫描仪)

How to get int in string (Scanner)

Scanner scanner = new Scanner ("2 text 3text");
scanner.nextInt(); // 2
scanner.next();    // text
scanner.nextInt(); // 3 ?

我想得到 int(3)。但是 int 没有与 space.

的字符串分开

如何将 int 与 string 分开?

将不是数字的字符拆分为数字:

String[] split = s.split("\D+"); // where s is your input string