我正在开发一个应用程序,在某个时候应用程序从 Facebook Graph API 接收一个字符串。
字符串看起来像这样:
"Some text some text, some text.\n\nMore text and more\n\nAnd little bit more".
Run Code Online (Sandbox Code Playgroud)
如何用换行符替换 \n\n 代码中实际有效的内容?
我知道如何用一些东西替换它:
var ret = stringToReplace.replace('\n\n','<br />');
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能用工作换行符替换它。我试图用 '\n' '\r\n' 替换。每个替换都像通常的文本一样。例如:
"Some text some text, some text.<br />More text and more<br />And little bit more"
Run Code Online (Sandbox Code Playgroud)