javascript turn single line break to double line break
Hm... I'm trying to convert single line break into double line break, as in
This is a sentence.
This is another sentence.
into
This is a sentence.
This is another sentence.
Apparently this doesn't work ThisC开发者_高级运维ontent = ThisContent.replace(/(\n)/gm, "\n\n");
since it replace everything, including double line breaks.
What's the regex to do this?
txt = txt.replace(/(^|[^\n])\n([^\n]|$)/g, "$1\n\n$2");
精彩评论