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

Source text




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.

  • I had never considered this, and you explained it exceptionally well. Thanks! – Wouter Apr 28 '17 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.