javascript:替换换行符
我有一个包含 chr(13) 作为换行符的字符串。我怎样才能用例如替换它。
?我尝试了 mystring.replace("\n","
但它不起作用,
");
提前致谢。
I'm having a string which contains a chr(13) as linebreak. How can i replace it with eg. <br>
? I tried mystring.replace("\n","<br>");
but it didn't work
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“\n”
是 chr(10)。我想你想要"\r"
:更新:要替换 ALL \r 使用正则表达式:
如果你希望它与 Windows、Unix 和 Mac 风格的换行符一起使用,请使用以下命令:
"\n"
is chr(10). I think you want"\r"
:Updated: To replace ALL \r use a regular expression:
If you want it to work with Windows, Unix and Mac style line breaks use this: