Get all digits from a string
public class Main { public static void main(String[] argv) throws Exception { System.out.println("abasdfasdf1 2wasdfasdf9_8asdfasdfz asdfasdfyx7".replaceAll("\\D", "")); } }