Here is my code:
echo "<br />";
preg_match_all("|<[^>]+>.*</[^>]+>|U",
"<b>example:</b><strong>this is a test</strong>",
$out, PREG_PATTERN_ORDER);
print_r($out);
echo "<br />";
echo "<br />";
preg_match_all("|<[^>]+>.*</[^>]+>|",
"<b>example:</b><strong>this is a test</strong>",
$out, PREG_PATTERN_ORDER);
print_r($out);
echo "<br />";
There is something I do not understand. What difference that is make when there is a U at the end of the regex?
The output is:
Array ( [0] => Array ( [0] => example: [1] => this is a test ) )
Array ( [0] => Array ( [0] => example:this is a test ) )
So what is happening here really? Which version is the greedy version and why?