Edit > Permute Lines > Unique
is great for removing duplicate from a list in Sublime Text. But what if I wanted to remove all matching results instead? For example:
james
james
bobby
mary
ann
ann
The above list of names would become:
bobby
mary
Because bobby
and mary
are the only names that only appear once.
If you don't mind your lines being sorted, you could do it like this:
(^.*$\\n)\\1+
Although, sorting wouldn't be necessary if all the duplicates are next to each other, as per your example. eg it would even work with the following:
james
james
bobby
mary
ann
ann
james
james
james
Note that this regex requires the last line to have a trailing newline character, if it is a duplicate, otherwise it won't find it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.