Solusi String Hanya Berisi Angka

String str = "{[a12.334tyz.78x]}";
str = str.replaceAll("[^\\d.]", "");

Result
"12.334.78".

String text = "-jaskdh2367sd.27askjdfh23";
String digits = text.replaceAll("[^0-9.]", "");
System.out.println(digits);

Result
"2367.2723"

Referensi

Post a Comment

Lebih baru Lebih lama