📅  最后修改于: 2022-03-11 14:52:21.139000             🧑  作者: Mango
// string contains numbers
String str = "The price of the book is $49";
// extract digits only from strings
String numberOnly = str.replaceAll("[^0-9]", "");
// print the digitts
System.out.println(numberOnly);