I'm trying to extract all content from an html page that exists between <h1> and </h1> tag. My code however pulls content between the </h1> and <h1> tags as well.
$string = 'onio<h1>Test1</h1>Bad Content<h1>Test2</h1>09knkj';
$pattern = '/<h1>(.*)<\/h1>/';
preg_match_all($pattern, $string, $matches);