0 votes
1 view
in Java by (4.1k points)

Trying to remove all letters and characters that are not 0-9 and a period. I'm using Character.isDigit() but it also removes decimal, how can I also keep the decimal?

1 Answer

0 votes
by (46.1k points)

Impliment this code:

String str = "a12.334tyz.78x";

str = str.replaceAll("[^\\d.]", "");

Now str will contain "12.334.78". this code:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...