How to select (remove) every 6th (Nth) line in a text file?
I am not sure of what you are asking for. You title is about selecting every 7th line in a textfile but your sample is not related to that.
Anyway, I am guessing that you want to select every 7th line in a text file with notepad++.
You can do something like this:
Remove the empty lines: Edit > Line Operations > Remove Empty Lines
With Search & Replace(on regular expression mode) you can use this expression:
- Search:
([^\n]*\n?){7}
- Replace:
$1
- Search:
P.S. If you want another nth line, just replace the number between the braces.
Admin
Updated on June 13, 2022Comments
-
Admin almost 2 years
I need to reformat a log file of similar format and have been using Notepad++ macros.
Example:
[00:55:48] Profile Information: [00:55:48] Name: Joe Bloggs [00:55:48] Age: 21 [00:55:48] Profile Information: [00:55:48] Name: Joe Bloggs 2 [00:55:48] Age: 22
I need the format to be:
Joe Bloggs 21 Joe Bloggs 2 22
I can do this with the following operations in a macro but that only gets me so far.
Remove timestamps [[^[]]*]
Remove empty lines Edit > Line Operations > Remove Empty Lines
Replace following with nothing Name: Age:
Then I would need to select every say, 2nd line and remove everything else so I am left with a list of every second line - something like:
21 22
Hoping someone more familiar with Regex and such can chime in with pointers and advice.