Regex Expression to catch all headers and Subheaders

Hey everyone I trying to write a regular expression that catches all headers and subheaders in html code here is what I have so far

let html = "<h1>This is a header</h1> hello there <h2>This is a subheader</h2>"
let headerRegex  = /(<h[0-9]>.*?<\/h[0-9]>)+/;

and the console output is the following.

[ '<h1>This is a header</h1>',
  '<h1>This is a header</h1>',
  index: 0,
  input: '<h1>This is a header</h1> hello there <h2>This is a subheader</h2>',
  groups: undefined ]

As you can see it captures the h1 header twice. I cannot figure out how I can get it to capture both headers completely while also ignoring the text inbetween them.
Any help would be appreciated. Thank you!

Hello there,

I am not entirely sure what you are wanting, but it sounds like you just need to add the global (g) flag to your regex.

Yep that worked, thanks