Computer Science, asked by akshat1366, 1 year ago

How to replace all alphabets not digits in a string by space?

Answers

Answered by Avanish010
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