I’m currently using a regular expression to convert a textarea value’s new lines to <p> tags, this newly formatted block of text is then inserted on the page and it’s working fine. The block of text can be re-edited though, i.e. putting the block of text back in to the textarea for editing. Is there a regular expression I can use to replace the <p> tags with new lines again, so that the spacing is preserved as they’re editing the text within the textarea?
(This is to be used with JavaScript / jQuery).
I suggest you leverage jQuery’s queries to get the contents of each
<p>, and then join them with\n: