I need to check inside a given string, if a character is contained while another not e.g. It needs to contain ‘a’ but not ‘b’.
I tried with something like:
echo preg_match('/(?:a)(?!b)*$/','hi a good day')
I tried with the lookahead, but I am missing something … the first part matches the second does not because it should be valid for the length of all the string and not just for some.
So I tried also with
echo preg_match('/^(?:a)[^b]*$/','hi a good day');
and it does not match, what am I missing ?
( I know I could use strpos but I would like to use a regex approach ).