Regular expression using negative lookbehind not working in Notepad++

前端 未结 3 478
我寻月下人不归
我寻月下人不归 2020-12-17 14:05

I have a source file with literally hundreds of occurrences of strings flecha.jpg and flecha1.jpg, but I need to find occurrences of any other

3条回答
  •  庸人自扰
    2020-12-17 14:43

    Are you aware that you're only matching (in the sense of consuming) the extension (.jpg)? I would think you wanted to match the whole filename, no? And that's much easier to do with a lookahead:

    \b(?!flecha1?\b)\w+\.jpg
    

    The first \b anchors the match to the beginning of the name (assuming it's really a filename we're looking at). Then (?!flecha1?\b) asserts that the name is not flecha or flecha1. Once that's done, the \w+ goes ahead and consumes the name. Then \.jpg grabs the extension to finish off the match.

提交回复
热议问题