RegEx Replace button doesn't work as expected with a look-behind.

  • Today I found that when using the “Replace” button when using a positive lookahead and a capture group Notepad++ doesn’t replace anything. It only iterates through like “Find Next”.

    For example in the Changelog for the latest version If I wanted to remove the new lines between all the plugin versions with a regex.
    Excerpt from Changelog to remove newline characters:

    1. NppExport v0.2.8
    2. Plugin Manager 1.3.5
    3. Converter 3.0
    4. Mime Tool 1.9
      use the regex: (?<=.\d)(\r\n)
      Set the replace with as a space or comma.

    If I press “Replace All” the replace works on all 4 lines as expected. But, if I just try the “Replace” no replacements are made.
    If I don’t use a lookahead the “Replace” button works as expected.

    Is there a reason for this behavior?

  • Hello Joe,

    The behaviour of the N++ regex engine is quite bugged, if your regex contains “backward” assertions, as \A or look-behind, as (?<=xxx) and also if you use the \K syntax . In that case, the step by step replacement, with the Replace button, will NEVER work :-(( Therefore, you must use the Replace All button, exclusively !

    Just note that “forward” assertions, as \z and positive or negative look-ahead, as (?=xxxx) or (?!xxxx), work fine and that the use of the Replace button is effective !

    BTW, many thanks to you for your regex, as a reply to greg marshall. Refer to the address, below :

    Indeed, it helped me to find out a general regex, to get all the work done, in one go !

    Best Regards,


  • Reading this posting, it strikes me that perhaps the title should be

    "RegEx Replace button doesn’t work as expected with a look-behind."

    rather than

    “RegEx Replace button doesn’t work as expected with a positive lookahead.”

  • Scott,
    You are correct on the title of the post. I posted too late, and did mean the look-behind as you mentioned. When i tried to edit the post, I was given an error stating it can only be edited withing 180 seconds. I’ll poke around a bit, and see if I have any luck to correct the title.

    Guy038 thanks for the response. I did notice that other regex did appear to work. Was curious why the look behind didn’t work.

    Thanks again.


  • Title updated.

Log in to reply