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

Make a new line after 3 character after regex

I have following list:

Intel(USA)
Pfizer(USA)6
GeneralElectric(USA)43
Alphabet(Google)(USA)

I can select latest ( in each line by ^.*\K\((?=[^(]*$) regex.
Now I want to make a new line after 3 character after my regex.
for example I get following result:

Intel(USA
)  
Pfizer(USA
)6  
GeneralElectric(USA
)43  
Alphabet(Google)(USA
)  

how to do this by regex and what changes I must apply to my regex?
Note that for some reason I must create a regex for latest ( and can’t use latest ) and note that provide regex for Notepad++

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

>Solution :

You can match until the last ( and then match optional chars other than ( and )

Then forget what is matched so far, and assert the closing )

In the replacement use a newline.

^.*\([^()\r\n]*\K(?=\))

Regex demo

Or match 3 chars A-Z

^.*\([A-Z]{3}\K(?=\))

Regex demo

enter image description here

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