Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I replace the no break space (nbsp) with a normal space? [closed]

Tags:

java

ascii

I see that in many examples it is simply this:

message.replaceAll(nbsp, " ");

Of course it is saying local variable nbsp not found though. How can I simply replace any nbsp in a string with the normal space?

like image 406
user3029760 Avatar asked Dec 26 '22 13:12

user3029760


2 Answers

You need to create a local variable String nbsp = " "

or simple use message.replaceAll(" ", " ");

This will also work:

message.replaceAll("\u00a0"," ");
like image 161
Zeeshan Avatar answered Apr 16 '23 22:04

Zeeshan


Try:

String message = "a b c";
String nbsp = " ";
message = message.replaceAll(nbsp, " ");
System.out.println(message);

Output: "a b c"

like image 30
Yser Avatar answered Apr 16 '23 23:04

Yser