Did I just find a bug in Notepad++'s lookbehind implementation?

I am using Notepad++ v7.3.3, and am testing the following Regex:

Source text

aa

Pattern

(?<!a)a

This is returning two matches. The first a, and the second a. When testing this expression on regex101 it only returns one match (the first a).

Why is Notepad++ also matching the second a? Could this be a bug?


It's not a bug... Notepad++ "search" when you have DOWN selected, does not recognize any characters BEFORE the cursor. When you selected the first a, your cursor moved. So once your cursor is passed the first a, it then matches the remaining a. The same could be said about searching "UP", it will ignore any character from the cursor to the end of the document.

Your regex hasn't failed, it's just you have to remember and understand the nature of the text editor in general.

Regex 101 didn't perform a "partial" string lookup like Notepad++ did. However you can correct this by using anchors in your regex. You could Anchor this regex to the start of the line with ^. Then you wont get a match on your second a.

^(?<!a)a