+ 5

How can we replace a character with space ?

For example we have this line : 133-124 And we want it to be like : 133 124

6th Jan 2020, 10:32 AM
Maryam K
Maryam K - avatar
5 Answers
+ 7
Iterate into elements of your string(char[]) using a for loop and whenever you found "-" replace it with " " simple :)
6th Jan 2020, 10:57 AM
Abdol Hashimi
Abdol Hashimi - avatar
+ 5
BEN_10 thank u It's axactlly what i wanted
7th Jan 2020, 10:55 AM
Maryam K
Maryam K - avatar
+ 5
You do this by some few lines of codes : String sort= "133-124".replaceAll("[^a-zA-Z0-9 ]"," "); System.out.println(sort);
7th Jan 2020, 3:27 PM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 4
[DELETED] EDIT: Sorry, I didn't see you tageed C, my answer was valid for python only ^^"
6th Jan 2020, 11:36 AM
Aymane Boukrouh
Aymane Boukrouh - avatar