If the user enters exactly "null", I want the regex match to fail. Entering "xxxnullxxx" is ok however.
The following regex rejects "null" but it also rejects any string containing "null", which I don't want.
^(?!.*null).*$
If the user enters exactly "null", I want the regex match to fail. Entering "xxxnullxxx" is ok however.
The following regex rejects "null" but it also rejects any string containing "null", which I don't want.
^(?!.*null).*$
Add $ and remove .* from the look ahead:
^(?!null$).*
The trailing $ isn't needed.
This will match everything except for null: ^(?!(?:null)$).*$ I got the idea from here.