Search code examples
notepad++

Got stuck while using regular expression in notepad++


I have try try use notepad++ for separate the character using comma, after 4 character. but the output is not as expected.

output got:‭‭11,1111,1011,0011,1110,1111,1111,1111,11‬

expected output:‭‭1111,1110,1100,1111,1011,1111,1111,1111‬

I have attached an image.

enter image description here


Solution

    • Ctrl+H
    • Find what: (?:^|\G)....\K
    • Replace with: ,
    • CHECK Wrap around
    • CHECK Regular expression
    • UNCHECK . matches newline
    • Replace all

    Explanation:

    (?:^|\G)    # non capture group, beginning of lien OR restart from last match position
    ....        # 4 any character but newline
    \K          # forget all we have seen until this position
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here