Forum Moderators: coopster
Well, there are a few ways to accomplish your goal, but a zero-width, negative lookahead assertion [php.net] is the tool you will more than likely end up using. A lookahead assertion is a test on the characters following the current matching point that does not actually consume any characters. And in this case, it is a negative assertion or, "don't match this":
$string = "'Brenda Brown' and 'Brenda Jones' are OK, but not 'Brenda Smith'?";
// There's a space after Brenda in the next line:
preg_match_all("/'Brenda (?!Smith').*'/Uis", $string, $matches);
print "$string<br />";
print "<pre>"; print_r($matches); print "</pre>";
'Brenda Brown' and 'Brenda Jones' are OK, but not 'Brenda Smith'?
Array
(
[0] => Array
(
[0] => 'Brenda Brown'
[1] => 'Brenda Jones'
))