Negative lookahead Regular Expression

前端 未结 7 914
后悔当初
后悔当初 2020-11-27 14:00

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

7条回答
  •  粉色の甜心
    2020-11-27 14:35

    You could emulate the negative lookbehind with something like /(.|..|.*[^f]..|.*f[^o].|.*fo[^o])\.htm$/, but a programmatic approach would be better.

提交回复
热议问题