最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use negative lookahead (NOT lookbehind) to match a string that does NOT contain a given substring at a speci

programmeradmin8浏览0评论

I'd like to match certain file types (e.g., ".txt") with a non-empty root name that doesn't end in a particular substring (e.g., "-bad"). With negative lookbehind support, the solution is simple:

/.(?<!-bad)\.txt$/

Safari, however, still does not support negative lookbehinds. Ugh. How could I achieve the same result using a negative lookahead? I'd like to do this with a single regular expression. Please do not provide any non-regex or multi-step solutions.

The test code below shows that I'm close, but one test is still failing.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论