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

How to remove lines having textual data in notepad++

I have a specific format data as shown below in notepad++, i would like to remove lines having textual data like "This is first sentence".

1.(AB123456)  
2.This is first sentence  
3.(AD2341278) 
4.tHIS is second sentence
5.(ABCD1234)
6.4 (four) is a number

One hint is all the lines that i need have a bracket "(" , however in textual data there are brackets too.
I tried using other means like number of letters (5 or more letters, since there are maximum 4 letters even in one i need to retain)like in regex (.*[A-Za-z]){5,} , however it did not help me to delete the entire line.

Can anyone help me with simple regex solution to remove lines?

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

notepad++ looks like this
enter image description here

Desired output should look like this
enter image description here

>Solution :

Case 1: Matching lines like (AB123456)

You can try chaining your match to spaces + end of line character [\s]*($|\n) and retrieve all alphanumeric characters between parentheses \([\w]+\).

\([\w]+\)[\s]*($|\n)

Case 2: Matching lines like This is first sentence

You can try chaining your match to the start of line character (\n|^), catch the first character as a non opened parenthesis ‘[^(]’, then match everything else on the same line .*.

(^|\n)[^\(].*
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