I've read through numerous posts on preg_match and can't find the answer. How to fail the whole preg_match when only one part of the haystack fails? I simply need to fail the whole preg_match, when the haystack ends with dot-anything (e.g., .html).
The groupings in here, before the problem area, are needed for other purposes and can't be changed. The portion I want to fail, when it contains a dot, is: ([^\.])*
If that fails, the entire preg_match needs to fail. Note: the dot is only a "failing dot" if it occurs after the hyphen. There are dots before the hyphen that are not failing dots.
Everything on the right-hand side of the OR operator is fine. Nothing needs to be changed there.
preg_match('#^(.*)\/([0-9]+)\-([^\.])*|(.*)id_category=([0-9]+)(.*)$#', $haystack, $return_array)
Since I'm not evaluating the entire string for the dot, I have not been successful with negative lookahead. It only fails the one part, without failing the whole preg_match.