'How to bookmark every 5th row in Notepad++

I need to extract every 6th row from a text document. I think the first step is to bookmark them. I'm looking for a regex expression that will do that.

thanks



Solution 1:[1]

If you just want to extract them, you can search for ([^\n]*\n?){5} (Starts with line one and selects every fifth).

Search with Find All in Current Document -> right click on the parent item of your current search in search results window -> Copy Selected Line(s).

Solution 2:[2]

To bookmark every 5th row in Notepad ++, go to Search > Replace menu (shortcut CTRL+H) and do the following:

  1. Find what:

     ([^\n]*\n?){5}
    
  2. Select radio button "Regular Expression"

  3. Then press Enter

Solution 3:[3]

  • Ctrl+H
  • Find what: (?:^.+\R){5}(^.+\R)
  • Replace with: $1
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

(?:         # non capture group
  ^           # beginning of line
    .+          # 1 or more any character but newline
    \R          # any kind of linebreak
){5}        # end group, must appear 5 times
(           # group 1
  ^           # beginning of line
    .+          # 1 or more any character but newline
    \R          # any kind of linebreak
)           # end group

Replacement:

$1      # content of group 1, the 6th line

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 jahantaila
Solution 3 Toto