Patterns are greedy by default, and made ungreedy by appending ? to quantifiers * and +.
For string
$s = '<div id=searchform>This should be shown.</div> But this should not.</div>';
A greedy pattern would capture too much. That is how it's supposed to work: capture as much as possible. I.e. the capturing subpattern (.*) would capture
This should be shown.</div> But this should not.
Also, you should use $match[1], which is the string matched by your subpattern, rather than $match[0] which is the string matched by the entire pattern. I.e. the difference between these
<!-- $match[0] -->
<div id=searchform>This should be shown.</div> But this should not.</div>
<!-- $match[1] -->
This should be shown.</div> But this should not.