Complementing regular expressions is a bad idea. It is possible, but very poor style, and can be ineffective; and negative statements that allow you to do this briefly can only mask inefficiencies. Almost always the best idea is to match the regular expression normally and invert the result with ! .
You should always write negative regular expressions if you absolutely need to, for example. if you must satisfy an API that can only be programmed by supplying one regext and nothing else.
source share