How to keep only the necessary part of the text in a line in Notepad++

- Press Ctrl+H to open the Find and Replace dialog box.
- Go to the Replace tab.
- Enable Regular expression mode at the bottom of the dialog box.
Example 1: Suppose you have lines like:
123abc456 789def012 345ghi678
And you want to keep only the part of the text with letters. To do this:
- In the Find field, enter:
\d+
After that, the lines will look like this:
abc def ghi
Example 2: Suppose you have lines like:
abc_123_def ghi_456_jkl mno_789_pqr
And you want to keep only the text after the first underscore and before the second underscore. To do this:
- In the Find field, enter:
^[^_]+_([^_]+)_.*$
\1
After that, the lines will look like this:
123 456 789
Now you know how to keep only the necessary part of the text in a line and remove the rest.