测试2
package DEMO01; import java.util.Scanner; public class Demo2 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.println("输入字符串"); String str=sc.next(); String s=str.replaceAll("[^0-9]", ""); System.out.println("原:"+str+"\n\n筛:"+s); } }