I want to match all strings ending in \".htm\" unless it ends in \"foo.htm\". I\'m generally decent with regular expressions, but negative lookaheads have me stumped. Why
As mentioned JavaScript does not support negative look-behind assertions.
But you could use a workaroud:
/(foo)?\.htm$/i.test("/foo.htm") && RegExp.$1 != "foo";
This will match everything that ends with .htm but it will store "foo" into RegExp.$1 if it matches foo.htm, so you can handle it separately.