Given this HTML as a string \"html\", how can I split it into an array where each header
Begin with this:>
In your example you can use:
/
// Match literal <
.*? // Match any character zero or more times, non greedy
<\/h // Match literal // Match literal >
/g
var str = 'A
B
Foobar
C
'
str.match(/.*?<\/h\1>/g); // ["A
", "B
", "C
"]
But please don't parse HTML with regexp, read RegEx match open tags except XHTML self-contained tags