Okay basically I'm looking for an expanded version of a negative character class. For instance, say I have this string:
$string = "
<a href='blah' id=1234.2>[FLAG] something</a>
<a href='blah' id=829.1>somethingelse</a>
<a href='blah' id=634.5>somerandomcharlength</a>
";
I want to capture the id but only if '[FLAG] ' between the anchor tag is not there. '[FLAG] ' will always be immediately after the closing '>' of the opening anchor tag and it will always have a space right after it. If it is not there, the stuff between the anchor tags will start immediately after the '>' for the opening tag (no space).
So for this example, I want to capture 829.1 and 634.5 but not 1234.2
I think the answer is negative lookbehind, so here's what I've tried:
preg_match_all("/<a.*?id=([0-9.]+)[^>]*?>(?<!\[FLAG\] ).*?<\/a>/",$string,$matches);
I've also tried wrapping the .*? in non-capturing parenthesis like so:
preg_match_all("/<a.*?id=([0-9.]+)[^>]*?>(?<!\[FLAG\] )(?:.*?)<\/a>/",$string,$matches);
But it continues to match all 3 ids. So...what am I doing wrong?