我对如何在js字符串中添加换行符有疑问。下面是代码:
{
"id": 7,
"last": 1,
"name": "Customer received Email to change the password/Received. And code that customer hasn’t requested"
},
我想在
password/Received
之后换行。我想要所需的输出Customer received Email to change the password/Received.
And code that customer hasn’t requested
最佳答案
如果要添加换行符并且无法修改文本的原点,则可以执行以下操作:
str = "Customer received Email to change the password/Received. And code that customer hasn’t requested";
str.replace("password/Received. ","password/Received.\n");
如果要以HTML格式输出,请用
\n
替换<br/>
。关于javascript - 在字符串中的特定位置添加换行符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52831999/