3

i have this data

aaa
aaa
bbb
ddd
bbb
ccc

how to keep only unique lines as this result

ddd
ccc

Thanks much for any help

user3528679
  • 63
  • 1
  • 6

4 Answers4

5

Try doing a find and replace all in regex mode with:

^(.*?\R)\1+

and replace with nothing.

Apologies, just observed this will not work is list is not sorted.

Penguin
  • 171
  • 1
  • 9
3

Two step

1st : Edit - Line Operations - Sort Lines Lexicographically Ascending
2nd : replace "(?-s)^(.+\R)\1+" with nothing

source :https://notepad-plus-plus.org/community/topic/12490/i-want-to-keep-only-unique-lines/2

Anyone can explain the answer ? .Thanks

user3528679
  • 63
  • 1
  • 6
1

For anyone still ending up here, you can now do:

Select text to operate on 
Edit->Line Operations->Sort Lines Lexicographically Ascending
Edit->Line Operations->Remove Consecutive Duplicate Lines
StephenL
  • 43
  • 5
0

user3528679's answer works, except there's one correction in the second step.

For the regex find and replace, do not replace with nothing/blank, instead replace with the captured string in the capture group (replace with $1)

The regex selects a group of one or more consecutive duplicates. Replacement with $1 will replace the whole group with the captured string.