What are the advantages of using non-greedy quantifiers in PHP regex patterns?

Non-greedy quantifiers in PHP regex patterns are useful when you want to match the smallest possible portion of a string that satisfies the pattern, rather than the largest possible portion. This can be helpful when dealing with patterns that may have multiple matches within a single string, as it ensures that each match is as minimal as possible. Non-greedy quantifiers are denoted by adding a "?" after the quantifier symbol.

$string = "This is a sample string with multiple matches";
$pattern = '/is.*?m/';
preg_match_all($pattern, $string, $matches);
print_r($matches[0]);