Created
June 29, 2018 16:05
-
-
Save acemir/204612360042109a33e1d372761ad877 to your computer and use it in GitHub Desktop.
Match literal \r\n and trasform to <p></p>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Match literal \r and literal \n | |
'<p>' + (str || '').split(/(?:\\[rn])+/g).join('</p><p>') + '</p>'; | |
// Match all carriage returns \r, newlines \n and also literal \r and literal \n | |
'<p>' + (str || '').split(/(?:\\[rn]|[\r\n]+)+/g).join('</p><p>') + '</p>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment