替换字符串中的子字符串

贾斯

我有一个String userId:344556\\ncustomerId:233

我想\\n用新行替换子字符串所以我尝试了

String more = strmoreInfo.replace("\\n", "\n");

我想要的输出是:

userId:344556
customerId:233

但是我当前的输出是:

userId:344556\
customerId:233

我究竟做错了什么?

移动

'\'是转义字符。您需要将语句更改为:

String more = strmoreInfo.replace("\\\\n", "\n");

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章