My regex until now:
<h1>(.*?)<\/h1>(.*?)(?:<h1>)?
My test String:
<h1>Foo</h1><h2>Bar</h2><h1>Baz</h1><h3>Test</h3><h1>ghj</h1>zuio
Right now the part (.*?)
is matching the shortest String possible, but what I actually want is that it matches everything until the next match (meaning for the first match: <h2>Bar</h2>
, for the second <h3>Test</h3>
and so on (underlined in the picture below)).
Can anyone help me?