Delete multiple lines if one line contains certain string in notepad++

1

I have multiple lines for my website and now I want to clear up a few of them.

Is there a way I can mark (or atleast delete) groups of lines that all contain a certain string? For example.

====================================
Account: emailaddress1@email.com:password
Orders:
No orders found.
====================================

====================================
Account: emailaddress2@email.com
Orders:
Item 1.
Item 2.
Item 3.
====================================

====================================
Account: emailaddress3@email.com
Orders:
No orders found.
====================================

I have that but on a large scale and I want to remove the whole group (including spaces) that contain the string No orders found or preferable mark them so I can move them to a different document.

Thanks

Ollie

Posted 2014-12-31T17:20:39.247

Reputation: 15

I don't know if Notepad++ supports it but you can use a regex pattern like this one: '=(.*)=(.*)No\ orders\ found\.(.*)=(.*)=' and replace the match with an empty string ''. I think that'll match anything that starts with a row of '=' has 'No orders found.' in the middle and ends with another row of '=' (I haven't checked it yet). – arielnmz – 2014-12-31T17:25:13.630

Have you tried "Find and Replace" option?. Press Ctrl+H and provide "Find What" and "Replace With" and then click on Replace All. Will this helps? – vembutech – 2014-12-31T17:28:28.453

@vembutech unfortunately this will only remove the string I enter and as the email:pass is dynamic and changes it won't work – Ollie – 2014-12-31T17:36:06.693

Answers

0

Try this work around

press ctrl+H to open replace windows(search mode: Regular expression)

find : \r\nNo orders found
Replace with :No orders found

This will give the output like below and replace only the group which contains "No orders found"

====================================
Account: emailaddress1@email.com:password
Orders:No orders found

====================================

Step 2:

find : \r\nOrders:No orders found
Replace with :Orders:No orders found

This will give the output as follows

Account: emailaddress1@email.com:passwordOrders:No orders found

Now find the word "No orders found" and delete entire line

find : \r\n.*No orders found
Replace with :

Hope this helps!

vembutech

Posted 2014-12-31T17:20:39.247

Reputation: 5 693