Find and copy a specific line from a file
-
Hello dear notepad++ user,
I have a text file,
and the data is always in this format:Name: xxx
Family name: xxx
Date of birth: xxxxx
Street: xxxxx
No.: xx
City code: xxxxxx
City: xxxxxxxx
Floor: xxxx
Location: xxxxx
Telephone: xxxxxxxx
Email: xxxxxxxxx@xxxxxxxxxxx.xx
IBAN: xxxxxxxxxxxx
xxxxxxxxxI only want to copy the line “E-Mail” into another file,
preferably separated by commas,so he should copy the content of the line e-mail: after the colon into a separate file or into the same file somewhere at the end, preferably one after the other. so
xx@xxxxxxx, xxxxxxxx@xxxx, xxxxxx@xxxxxxx, xxxxxxxxxx@xxxx, xxxxxxx@xxxxxx,
thanks
-
@Mobil-Meister said in Find and copy a specific line from a file:
I only want to copy the line “E-Mail” into another file
This is fairly simple. It can be achieved in a few steps. My thoughts were that you work on a copy of the file and use the Mark (bookmark) function.
So once the (copied) file is opened in Notepad++ Go to “Search”, then “Mark”. You can type in
Email:
, select (tick) bookmark and then click “Mark All”. Note that as the text you are searching for doesn’t change your search mode can be “Normal”. Every line which has this text will be marked with a blue circle in the left margin.
Close the Mark function and right click in the left margin and select “Remove unmarked lines”.
You are now left with ONLY the Email lines of the file. Now you can use the Replace function. This time you will be replacing the Email: (and CR and LF) with a comma.
So Find What:(?-s)Email:( .+)\R
Replace With:${1},
This is a regular expression so set the search mode as regular expression. Click on Replace All. You should now have the result you want.Terry
-
@Terry-R oh my god,
actually completely logical, i just didn’t have the idea. thank you. notepad++ is really a super tool.