can this be done using only one regular expression?
Edit: Please, don't complain about me parsing HTML :) The same situation can be reproduced with plain text :
Supposed source string:
Lorem 1 ipsum. Lorem 2 ipsum TOKEN
foo. Lorem 3 ipsum
Supposed source string HTML version:
<div id="entry-1">Lorem ipsum</div>
<div id="entry-2">Lorem ipsum TOKEN</div>
<div id="entry-3">Lorem ipsum</div>
What I want to get:
2, because that "Lorem ipsum" contains the token.
I'm trying it using: /([0-9]+).*TOKEN/sm
, but I get 1, because it starts looking for TOKEN after finding the first "digit", that is 1.
Using two separated regex/preg_match it's easy, but I wonder if this approach could be improved.
Thanks in advance for your help :)