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.
A normal “Find and Replace” can't do that, but it's possible with “Regular Expressions”. In Notepad++ press Ctr+H to open the “Find and Replace” window. Under Search Mode: choose “Regular expression” and then check the “matches newline” checkbox.
Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
Replacing text within NotepadOpen the text file in Notepad. Click Edit on the menu bar, then select Replace in the Edit menu. Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement.
Capturing groups are a way to treat multiple characters as a single unit. They are created by placing the characters to be grouped inside a set of parentheses. For example, the regular expression (dog) creates a single group containing the letters "d" "o" and "g" .
Try using:
^((?:\b[A-Z]+\b\s+)+)(?:.*)(\d{8})
And replace with:
\1\2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With