I'd like a regex that matches paragraphs, so for example :
The red brown fox, did something. [newline] I don't remember this text.
[newline]
[newline] So, instead I'll say blah blah. [newline] Blah.
would return an array like this:
['The red brown...', 'So instead I'll say...']
I already have this regex (that I stole, shh): /(?:[^\r\n]|\r(?!\n))+/gm
However this pattern matches both linebreaks (one newline) and paragraphs breaks (two newline). How can I match the body of text between paragraphs, but not split the matches between single linebreaks?
.match(/(?:.|(?:\r?\n|\r)(?!\r?\n|\r))+/g)but I do not like it. This is good:s.match(/.+(?:(?:\r?\n|\r)(?!\r?\n|\r).*)*/g). Splitting is better:var s = "The red brown fox, did something.\r\nI don't remember this text.\r\n\r\nSo, instead I'll say blah blah.\r\nBlah."; console.log(s.split(/(?:\r\n){2,}/g));