正则表达式 : want to find all links that do not end in ".html"

标签 regex notepad++ negative-lookbehind negative-lookahead

我是正则表达式的新手(尽管我已经成功使用过很多次)。 我想查找文档中不以“.html”结尾的所有链接 我想出的正则表达式是:

href=\"([^"]*)(?<!html)\"

在我的编辑器 Notepad++ 中,href=\"([^"]*)\" 查找所有链接(以“html”结尾的链接和不以“html”结尾的链接)。 为什么消极的后视不起作用?

我也尝试过前瞻:

href=\"[^"]*(?!html\")

但这也没有用。

有人可以帮忙吗?

干杯,卑躬屈膝

最佳答案

如果您使用的是 PERL 或 PCRE(例如 PHP 中的 preg_match),该正则表达式可以正常工作。但是,大多数不支持前瞻和后瞻断言,尤其是更简单的正则表达式引擎,例如 Notepad++ 使用的引擎。几乎所有的正则表达式引擎都只支持最基本的语法,例如量词、子模式和字符类。

您可以在以下位置找到 notepad++ 正则表达式引擎的文档:http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions

关于正则表达式 : want to find all links that do not end in ".html",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2514885/

相关文章:

java - 正则表达式检查中间 3 个字符

regex - 如何在 .htaccess 中从一个子域重定向到另一个子域?

regex - Notepad++ 正则表达式组捕获语法

lisp - 在 Notepad++ 中编译 lisp/scheme

regex - 负先行正则表达式在 ES dsl 查询中不起作用

java - 在字符串中搜索单词

javascript - 从输入字符串中获取包含字符及其 ANSI 颜色的数组

php - 需要可变宽度负向后查找替换

linux - 复制特定字符前面的输出(:*:) from each line in a list using Notepad++ or in linux

javascript - 否定后视不匹配转义字符,在转义反斜杠上失败