Description
无重力学长喜欢玩dota2,狙击枪学长喜欢玩nba2k,但是他们不喜欢英文字母,所以想请大家帮个忙。
Input
第一行给出输入组数t,共有t组测试数据,每组给出一个字符串
Output
字符串中的数字
Sample Input
2dota2nba2k
Sample Output
22
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n = Integer.parseInt(cin.nextLine());
while(n-->0){
String str = cin.nextLine();
System.out.println(str.replaceAll("[^0-9]","" ));
}
}
}