Search code examples
notepad++

How to replace a new line for each 10 number of commas


I have a set of numbers separated by commas in the notepad++ document. I want to set a new line after every 10 number of commas/ or 10 no of numbers. How do i do this?

have this list

19406,20894,21138,21140,21142,21775,22097,34420,35455,35873,35892,35965,37373,37378,37380,37391,37398,37404,37406,37452,37454,37456,37849,37861,38080,39039,42445

need below..

19406,20894,21138,21140,21142,21775,22097,34420,35455,35873,
35892,35965,37373,37378,37380,37391,37398,37404,37406,37452,
37454,37456,37849,37861,38080,39039,42445

Solution

    • Ctrl+H
    • Find what: ^(?:\d+,){10}\K
    • Replace with: \n # you may use \r\n for windows linebreak
    • check Wrap around
    • check Regular expression
    • Replace all

    Explanation:

    ^       # beginning of line
    (?:     # non capture group
      \d+   # 1 or more digits
      ,     # a comma
    ){10}   # end group, appears 10 times
    \K      # forget all we have seen until this position