How to replace all alphabets not digits in a string by space?
Answers
Answered by
0
HI there,
Try this in the main body;
String str = "a12.334tyz.78x";
str = str.replaceAll("[^\\d.]", "");
Thanks
Answered by
1
Answer:
Java uses a replace function that returns characters :---
Syntax :- String stringname =String.replace('m' ,'n');
m= the charactera in string that is to be replaced.
n=the characters that are replaced by this character.
Example:--
String a="Banana";
String t=a.replace('a','e');
System.out.println(t);
OUTPUT :-- Benene
Similar questions