Regular Expressions 101

Community Patterns

Removes duplicate lines in text editor

3

Regular Expression
PCRE (PHP <7.3)

/
^(.*?)$\s+?^(?=.*^\1$)
/
gms

Description

"dot matches newline" must be activated. Search and replace by "" (empty string) removes duplicate lines anywhere in text.

Example for Notepad++ use shown under http://stackoverflow.com/questions/3958350/removing-duplicate-rows-in-notepad

Submitted by Stackoverflow user stema - 8 years ago