[0-9] : 0 ~ 9의 숫자
[^0-9] : 0 ~ 9의 숫자를 제외한 문자
\s : \n, \t 등의 모든 공백을 제외한 문자
String str = "안12 녕3\t45하 \n ,/세67요89";
String intStr = str.replaceAll("[^0-9]", "");
String newStr = str.replaceAll("\\s", "");
System.out.println("intStr : " + intStr);
System.out.println("newStr : " + newStr);
> intStr : 123456789
> newStr : 안12녕345하,/세67요89
cf) replaceAll의 시간 복잡도 : O(n)