Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find duplicates and delete all in notepad++

I have multiple email addresses. I need to find and delete all (including found one). Is this possible in notepad++?

example:[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected],

I need results back like

[email protected], [email protected], [email protected], [email protected], [email protected], [email protected],

How to do in notepad++?

like image 928
James123 Avatar asked Feb 11 '16 01:02

James123


People also ask

Can Notepad ++ remove duplicate lines?

Notepad++ with the TextFX plugin can do this, provided you wanted to sort by line, and remove the duplicate lines at the same time.


1 Answers

If it is possible to change the sequence of the lines you could do:

  1. sort line with Edit -> Line Operations -> Sort Lines Lexicographically ascending
  2. do a Find / Replace:
    • Find What: ^(.*\r?\n)\1+
    • Replace with: (Nothing, leave empty)
    • Check Regular Expression in the lower left
    • Click Replace All

How it works: The sorting puts the duplicates behind each other. The find matches a line ^(.*\r?\n) and captures the line in \1 then it continues and tries to find \1 one or more times (+) behind the first match. Such a block of duplicates (if it exists) is replaced with nothing.

The \r?\n should deal nicely with Windows and Unix lineendings.

like image 172
Lars Fischer Avatar answered Nov 20 '22 21:11

Lars Fischer