How can the use of regular expressions in PHP lead to unexpected results when dealing with nested tags and content extraction?

When using regular expressions in PHP to extract content from nested tags, the greedy nature of regular expressions can lead to unexpected results. This is because regular expressions will match the longest possible string that satisfies the pattern, which can cause issues when dealing with nested tags. To solve this problem, you can use a non-greedy modifier such as `?` to make the quantifiers lazy, ensuring that the shortest match is found.

<?php
$html = '<div><p>This is some <strong>bold</strong> text</p></div>';
preg_match('/<div>(.*?)<\/div>/', $html, $matches);
echo $matches[1]; // Output: <p>This is some <strong>bold</strong> text</p>
?>