String newStr = oldStr.replaceAll("[^\\d.]+", "")
This will drop any character that is not either a digit or a period
More Related Contents:
- String concatenation containing Arabic and Western characters
- How to add to string number and keep string in Java?
- Why is char[] preferred over String for passwords?
- Java: splitting a comma-separated string but ignoring commas in quotes
- Split string with dot as delimiter
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- How to convert comma-separated String to List?
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- Concatenating null strings in Java [duplicate]
- Is there a way to instantiate a class by name in Java?
- Is it good practice to use java.lang.String.intern()?
- Why is String.chars() a stream of ints in Java 8?
- Test if a string contains any of the strings from an array
- Get the index of a pattern in a string using regex
- How do I check that a Java String is not all whitespaces?
- Copying to the clipboard in Java [duplicate]
- Performance penalty of String.intern()
- How much memory does a string use in Java 8?
- Can I get an enum based on the value of its field?
- How to replace a String in java which contains dot?
- String concatenation complexity in C++ and Java [duplicate]
- Java String.substring method potential memory leak?
- Validate a file name on Windows
- The split() method in Java does not work on a dot (.) [duplicate]
- Remove ✅, 🔥, ✈ , ♛ and other such emojis/images/signs from Java strings
- How do I apply the for-each loop to every character in a String?
- How to replace first occurrence of string in Java
- Is there an open source java enum of ISO 3166-1 country codes
- What is the most efficient way to convert an int to a String?
- Java: Checking equality of arrays (order doesn’t matter)