/(?:^|\n)##\s[^\n]*\n(.*?)(?=\n##?\s|$)/gs
(?:^|\n) // make sure we're at the start of a line
##\s // match only H2 tags
[^\n]*\n // skip the heading name
(.*?) // match heading content lazily
(?= // use a lookahead as to not consume the next heading's start tag
\n##?\s // terminate at H1 and H2 headings...
|$ // ...or at the end of the file
)