Regex: Add .dot at every 8 words

I need to put a dot after every 8 words. My regex is not so good:

SEARCH: ((\w+){8})

REPLACE BY: \1.


Solution 1:

  • Ctrl+H
  • Find what: (?:\S+\s+){7}\S+\K
  • Replace with: .
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

(?:         # non capture group
    \S+         # 1 or more non space
    \s+         # 1 or more spaces
){7}        # end group, must appear 7 times
\S+         # 1 or more non space
\K          # forget all we have seen until this position

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here