javascript turn single line break to double line break

Posted by Eric Sim on Stack Overflow See other posts from Stack Overflow or by Eric Sim
Published on 2010-05-11T04:07:26Z Indexed on 2010/05/11 4:14 UTC
Read the original article Hit count: 301

Filed under:

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 ThisContent = ThisContent.replace(/(\n)/gm, "\n\n"); since it replace everything, including double line breaks.

What's the regex to do this?

© Stack Overflow or respective owner

Related posts about JavaScript