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 regex areas to next line

I have a list like following:

WiytynXtP
54.76%
Witrn20t0t0
30.83%
Wrtinrt9t8
8.37%
Litrrtnurtrtx
3.17%
MtrtacrtS
2.60%
inrt9rtrt5/0.27%
Jul2004

Now I want to move all percentage values to next line using notepad++ regex.

I use following regex but not working for inrt9rtrt5/0.27% word

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 : (\d+\.\d+%)(\R)  
Replace : \1\2\2

I need something like following result:

WiytynXtP

54.76%
Witrn20t0t0

30.83%
Wrtinrt9t8

8.37%
Litrrtnurtrtx

3.17%
MtrtacrtS

2.60%
inrt9rtrt5/
0.27%
Jul2004

How to fix this?

>Solution :

You might use a match only without any capture groups:

\d+\.\d+%\R

The pattern matches:

  • \d+\.\d+% Match 1+ digits, a dot, 1+ digits and %
  • \R Match any newline unicode sequence

In the replacement use a newline and the full match

\n$0

See a regex demo


If you want to prepend the same newline that is matched by (\R) then you can use the capture group in the replacement, followed by the whole match:

\d+\.\d+%(\R)

And replace with

$1$0

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