Notepad ++ delete lines containing duplicate words

I have a txt document containing one word followed by a date on one line, etc. in each row. How does notepad ++ recognize the same words in different lines and remove duplicate lines?

+4
source share
4 answers

Assuming dates can be different for the same match of the same word, and you want to keep the one that appears first in the file, then this should work (make sure your file ends with a new line for this):

  • Go to the Replace dialog box (you can do Ctrl + F and go to the replacement tab)
  • In the "search mode" at the bottom, select "Regular Expression" (make sure that ". Matches the new line" is not selected)
  • In the "Find What:" field, enter (\s*\w+ )(.*\r\n)((.*\r\n)*)\1.*\r\n
  • In the field "Replace with:" enter \1\2\3
  • Click Replace until more cases appear (Replace All does not seem to work for this, there may be a better regular expression for which it will work, but I did not find it).

I tested this in a file:

 testing330 05:09-24/08 whatever 10:55-25/08 testing 15:57-26/08 testing667 19:22-30/08 linux 00:29-31/08 testing330 00:29-31/08 windows 12:25-31/08 

and the result:

 testing330 05:09-24/08 whatever 10:55-25/08 testing 15:57-26/08 testing667 19:22-30/08 linux 00:29-31/08 windows 12:25-31/08 
+2
source

Not a direct answer to your question, but I found this article based on the title. I just wanted to remove duplicate lines. I found an easy way to do it here.

  • Check all text (CTRL + A). Press "TextFX" β†’ "TextFX Tools" β†’ "Check" + "Sort" displays only UNIQUE lines (in the column) (if they have not been marked yet).
  • Click TextFX -> Click TextFX Tools -> Click "Sort Strings Case Insensitive" (in the column)
+7
source

You can use EditPlus on Windows or TextWrangler on Mac to easily sort and delete duplicate lines.

After Notepad ++ 6.5.2 (free), you can sort the lines or you can install the TextFX Symbols plugin using the Plugin Manager ,.

TextFX contains many features to convert selected text. Thanks to: * Interactive coordination with Brace * Processing quotes * Character random rotation * Text rewinding * Lineup column * Fill Text Down * Paste text counter down * Convert text to code * Numeric Conversion * URI and HTML encoding * HTML for text conversion * Send text in W3C * Sorting text * Ascii diagram * Correcting spaces * Autoclose HTML and brackets Homepage: http://textfx.no-ip.com/textfx/

+2
source

For me personally, here are the steps that I follow. Assume that column A has only 1 data column.

  • Import data into Excel.
  • Sort data.
  • Insert a function to check for duplicates. Cell B2 will be: = IF (A2 = A1, "Duplicate", "")
  • Select all columns B.
  • Copy
  • Insert custom and paste values.
  • Sort data according to column B.
  • Remove all those marked with the β€œDuplicate” symbol.
  • Copy data back to Notepad ++

I thought there was such a plugin, but it cannot find it now. Otherwise, this link may help you.

+1
source

Source: https://habr.com/ru/post/1501889/


All Articles