Search code examples
regexnotepad++

Move comma separated numbers after dot to next line


I have a list like following:

0.7,511,300
Lycthythtyjhos
4,465,688
Compusrteterterterve.World
3,827,911
Penthoutrtetet
1.2,148,123
Tripgtrgtrrtg
1,716,682
Dihtyhtyhtyh
01.1,115,456
Nov1995

Now I want to select comma separated numbers that placed after dot and move them to next line like following:

0.
7,511,300
Lycthythtyjhos
4,465,688
Compusrteterterterve.World
3,827,911
Penthoutrtetet
1.
2,148,123
Tripgtrgtrrtg
1,716,682
Dihtyhtyhtyh
01.
1,115,456
Nov1995

I tried following regex but not working for me!

Find What: (?<!\d)0*\K(?:\d{1,3}(?:,\d{3})+|(?!0+(?!\d))\d{1,4})(?!\d)
Replace With: \r\n$&

Find What: ^(?!\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b)[^\d\n]+\K[\d,]+
Replace With: \r\n$&

Find What: ^\d{1,3}(,\d{3})*$
Replace With: \r\n$&

How to fix this problem?
Note that last lines are dates and must keep without any changes.


Solution

  • want to select comma separated numbers that placed after dot and move them to next line like following

    ^\d+\.\K\d+(?:,\d+)+
    

    The pattern matches:

    • ^ Start of string
    • \d+\. Match 1+ digits and .
    • \K Forget what is matches so far
    • \d+(?:,\d+)+ Match 1+ digits and repeat 1+ times matching , and 1+ digits

    To match the whole line and prevent a partial match, add $ to the end of the regex.

    Replace with a newline and the full match:

    \r\n$0
    

    See a regex demo

    enter image description here