riser
riser

Reputation: 13

PHP preg match all

$str = <a href="keep.php?casuser=400000018623110" onclick="ajaxLinkSend('globalContainer', 'keep.php?casuser=400000018623110'); return false;" style="color:#ffca3e">

My working preg match all:

preg_match_all('/\'keep.php\?casuser=(.*) style=\"color:#ffca3e/iU', $result, $matches2);
$matches2[1][0] = 400000018623110'); return false;"

But I want only the numbers

No result with:

preg_match_all('/\'keep.php\?casuser=(.*)\'\); return false;" style=\"color:#ffca3e/iU', $result, $matches2);

Can anyone help me with that? And explain me why its not working? thx

Upvotes: 1

Views: 182

Answers (1)

OGHaza
OGHaza

Reputation: 4795

Slightly confused by the question - and I'd put this in a comment if I had the rep.

Is this sufficient

preg_match_all('/\'keep.php\?casuser=(\d*)/i', $result, $matches2);

or is it important that they also have the relevant style? If so try:

preg_match_all('/\'keep.php\?casuser=(\d*).*?style=\"color:#ffca3e/i', $result, $matches2);

Upvotes: 0

Related Questions