今天我试图删除一个简单文本文件中的重复行,例如:
input (list.txt):
hello
hello
try
output (list.txt):
try
我尝试使用 Notepad++ 删除重复的行并删除剩余的行,但什么也没有。 有没有软件或某些功能可以用 Notepad++ 执行此操作?
谢谢。
最佳答案
假设文件已排序,将所有重复行放在一起。
- Ctrl+H
- 查找内容:
^(.+(?:\R|$))\1+
- 替换为:
LEAVE EMPTY
- 选中环绕
- 检查正则表达式
- 请勿检查
。匹配换行符
- 全部替换
说明:
^ : beginning of line
( : start group 1
.+ : 1 or more any character but newline
(?: : start non capture group
\R : any kind of linebreak
| : OR
$ : end of line
) : end group
) : end group 1
\1+ : back-reference to group 1, may appear 1 or more times
给定示例的结果:
try
关于notepad++ - 如何删除重复行(文本文件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48039999/