如何将空格转换为 nbsp?这似乎对我不起作用:
String temp = "This is practice";
temp = temp.replaceAll(" ", "nbsp");
它实际上是在其中添加字符串 nbsp,我该如何制作它才能真正算作无中断空格?
最佳答案
要替换所有“空白”(空格、制表符等),请执行以下操作:
temp = temp.replaceAll("\\s", " ");
\s
是“空白”的正则表达式。
关于java - 如何将空格替换为 nbsp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20795499/