Negative lookahead Regular Expression March 5, 2023 by Tarik The problem is pretty simple really. This will do it: /^(?!.*foo\.htm$).*\.htm$/i.test("/foo.htm"); // returns false