Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 563
Kaah Avatar asked Jun 30 '13 16:06

Kaah


People also ask

How do you replace regex in Notepad?

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.

Can I use regex in Notepad?

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.

How do you replace in notepad?

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.

What is a capturing group regex?

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" .


1 Answers

Try using:

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

And replace with:

\1\2 
like image 80
Jerry Avatar answered Sep 16 '22 17:09

Jerry