Search code examples
replacenotepad++

Using found text in replace text


I want to add a new line before a date and the dates change so I use . to match 28/06/2023 -> ../../2023. I would like to still get \n28/06/2023 in the end result.

So my question is if you in Notepad++ can use the found text in the replacement text when using regex? Or if it is possible not to replace and just add a new line before the date?

Replace


Solution

  • Use capture group:

    • Find what: \d\d/\d\d/2023
    • Replace with: \n$0

    Where $0 contains the whole match.

    Another way is to use lookahead:

    • Find what: (?=\d\d/\d\d/2023)
    • Replace with: \n