Java String remove all non numeric characters but keep the decimal separator October 1, 2022 by Tarik Try this code: String str = "a12.334tyz.78x"; str = str.replaceAll("[^\\d.]", ""); Now str will contain "12.334.78".