gpt4 book ai didi

java - 如何将空格替换为 nbsp?

转载 作者:行者123 更新时间:2023-12-01 06:44:12 28 4
gpt4 key购买 nike

如何将空格转换为 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com