RegExp: want to find all links that do not end with ".html"

I am a relative newbie to regular expressions (although I have used them many times successfully). I want to find all the links in the document that do not end with ".html" The regular expression that I came up with is the following:

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

In Notepad ++, my editor href=\"([^"]*)\"finds all links (and those that end with "html", and those that do not). Why does a negative lookbehind not work?

I also tried to watch:

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

but that didn't work either.

Does anyone help?

Cheers grovel

+3
source share
5 answers

, PERL PCRE (, preg_match PHP). lookahead lookbehind , , , , Notepad ++. , , , .

notepad ++ : http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions

+8

Edit: Notepad ++ SciTE .

. http://www.scintilla.org/SciTERegEx.html


^.*(?<!\.html)$ >

+1

, , , , :

href=\"((([^"]*)([^h"][^"][^"][^"]|[^t"][^"][^"]|[^m"][^"]|[^l]))|([^"]|)([^"]|)([^"]|))\"
+1

.

.

+ ".html", ".html.html" ".html".

, href=\"([^"]*)\" href="\1.html", .html.html .html

, grovel

0

Note that Notepad ++ (now?) Supports assertions . (I have Notepad ++ 6.3 dated February 3, 2012.)

I believe that the Regular Expression Documentation implies that both replacement options use the same PCRE dialect:

  • standard: Search | Replace(default shortcut Ctrl H)
  • plugin: TextFX | TextFX Quick | Find/Replace(default shortcut Ctrl R)
0
source

Source: https://habr.com/ru/post/1738464/


All Articles