Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading