How can greediness be controlled in PHP regex patterns?

Greediness in PHP regex patterns can be controlled by using the "?" modifier after quantifiers like "*", "+", or "{ }". This modifier makes the quantifier non-greedy, causing it to match as little as possible. This can help prevent the regex from consuming too much of the input string.

$string = "I want to match <b>bold</b> and <i>italic</i> text";
preg_match('/<.*?>/', $string, $matches);
print_r($matches);