How to remove all letters except the first one in each line in Notepad++

- Open Notepad++ and load or open the file in which you want to make changes.
- Press Ctrl+H or select Search > Replace... to open the Replace window.
- In the Find field, enter the following regular expression:
([A-Za-z])(.*)
- In the Replace with field, enter:
\1
- Make sure the Search Mode option is set to Regular expression.
- Click Replace All to perform the replacement in all lines.
Detailed explanation:
The regular expression ([A-Za-z])(.*) works as follows:
- ([A-Za-z]) - captures the first letter in the line. Here,
[A-Za-z]
denotes any Latin character in upper or lower case. - (.*) - captures all subsequent characters in the line.
In the Replace with field, \1
is used to replace the entire line with only the first captured letter.
Example:
Suppose you have the following text:
abc
def
ghi
After performing the replacement, the result will be:
a
d
g
Using the above steps, you can remove all letters except the first one in each line of text in Notepad++.