Hello,
First of all - I'm quite new to Regex, but knowing the amount of work it could save me when programming, I thought I should learn it.
Well.. I came across a problem quite quickly. First of all, lets get to my code.
The CodeCODE
<?php
$xml = "<game id='123'>Testing, 123, 1</game> <game id='456'>Testing, 456, 1</game>";
preg_match_all("/<game id='[0-9]+'>.+<\/game>/", $xml, $matches);
print_r($matches);
The OutputQUOTE
Array
(
[0] => Array
(
[0] => <game id='123'>Testing, 123, 1</game> <game id='456'>Testing, 456, 1</game>
)
)
The ProblemWell, as you can see, I expected it, to cut it at </game>, as thats what I put in my regex (/<game id='[0-9]+'>.+<\/game>/), but it just carried on, till it got to the last </game> (I assume?)
Can anyone spread some light on this problem? as I'm SURE its something i've done wrong.
Thanks,
Richard