我有一个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] 删除。
我来说两句