String s = "Total Count :2, Correct Count :1, Wrong Count:1, Correct :India is great,, Wrong: where aer you";
我想要的是什么:
在int
变量中。
对我来说这是一个新手,我希望你们能帮助我。
答案 0 :(得分:5)
String s = "Total Count :2, Correct Count :1,Wrong Count:1, Correct :India is great,, Wrong: where aer you";
String[] ints = s.split("[^0-9]+");
int totalCount = Integer.parseInt(ints[1]);
int correctCount = Integer.parseInt(ints[2]);
int wrongCount = Integer.parseInt(ints[3]);
System.out.println(totalCount + " " + correctCount + " " + wrongCount); //2 1 1