Filip <fi************@mrbookmaker-nv.no.spam.be> wrote:
this is driving my crazy:
$set = '<Error Type="string" Value="System Error" /><ErrorCode
Type="int" Value="0" />';
preg_match('%<Error .*? Value="(.*)"%', $set, $matches);
echo $matches[1];
returns: System Error" />
why on earth does it include the " /> part when my pattern clearly asks
only to capture what's between the double quotes with "(.*)" ?
Because .* without trailing question mark will consume as many characters
as possible. In your example that would be:
<Error Type="string" Value="System Error" /><ErrorCode Type="int" Value="0" />';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle