Given this text:
1/12/2011
I did something.
10/5/2013
I did something else.
Here is another line.
And another.
5/17/2014
Lalala.
More text on another line.
I would like to use regex (or maybe some other means?) to get this:
["1/12/2011", "I did something.", "10/5/2013", "I did something else.\n\nHere is another line.\n\nAnd another.", "5/17/2014", "Lalala.\nMore text on another line."]
The date part and content part are each separate entries, alternating.
I've tried using [^] instead of the dot since JS's .* does not match new lines (as Matching multiline Patterns says), but then the match is greedy and takes up too much, so the resulting array only has 1 entry:
var split_pattern = /\b(\d\d?\/\d\d?\/\d\d\d\d)\n([^]+)/gm;
var array_of_mems = contents.match(split_pattern);
// => ["1/12/2011↵I did something else..."]
If I add a question mark to get [^]+?, which according to How to make Regular expression into non-greedy? makes the match non-greedy, then I only get the first character of the content part.
What's the best method? Thanks in advance.