Search code examples
regexnotepad++

Replace regexp capture-group in Notepad++?


Quick question: I have a regexp, ^(?:\b[A-Z]+\b\s+)+(.*)\d{8}, that gives two capture groups. I would like to replace capture group 1 with a whitespace. Is that possible?

If I do replace with: \1 it replaces TEST TESTER Hello, world. Another word here. 75793250 -> with Hello, world. Another word here. I want this result: TEST TESTER 75793250. Replacing the \1 with a whitespace.


Solution

  • Try using:

    ^((?:\b[A-Z]+\b\s+)+)(?:.*)(\d{8})
    

    And replace with:

    \1\2