public class Main { public static void main(String[] argv) throws Exception { System.out.println("ab1 2c9_8z yx7".replaceAll("\\D", "")); } }