Try this code:
String str = "a12.334tyz.78x";
str = str.replaceAll("[^\\d.]", "");
Now str
will contain "12.334.78"
.
More Related Contents:
- Java – how to replace duplicated characters in a string? [closed]
- Replace a character at a specific index in a string?
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- Remove all occurrences of char from string
- How can I check if a single character appears in a string?
- How can I format a String number to have commas and round?
- How to compare character ignoring case in primitive types
- Converting String to “Character” array in Java
- Creating Unicode character from its number
- How to determine if a String has non-alphanumeric characters?
- Java: How to split a string by a number of characters?
- foo(int) is not applicable for the arguments (String)
- How can I iterate through the unicode codepoints of a Java String?
- string to string array conversion in java
- Is a Java string really immutable?
- How to remove leading zeros from alphanumeric text?
- How to escape % in String.Format?
- Check and extract a number from a String in Java
- When are Java Strings interned?
- Why are strings immutable in many programming languages? [duplicate]
- Scanner only reads first word instead of line
- Best way to concatenate List of String objects? [duplicate]
- Convert JsonObject to String
- Why is String.length() a method?
- Is it possible to change the text color in a string to multiple colors in Java?
- Java compressing Strings
- What’s the best way to check if a String contains a URL in Java/Android?
- What’s the quickest way to compare strings in Java?
- Hints for java.lang.String.replace problem? [duplicate]
- What is difference between mutable and immutable String in java