是否有可能在notepad++中删除重复的行,只留下一行的单一出现?
当前回答
如果行是紧挨着的,那么你可以使用正则表达式替换:
搜索模式:^(.*\r?\n)(\1)+
替换为:\1
其他回答
从notepad++版本6开始,你可以在搜索和替换对话框中使用这个正则表达式:
^(.*?)$\s+?^(?=.*^\1$)
什么都不替换。这将在所有重复行中留下文件中最后一次出现的内容。
不需要排序,重复的行可以在文件中的任何地方!
您需要勾选“正则表达式”和“正则表达式”选项。匹配换行符”:
^ matches the start of the line. (.*?) matches any characters 0 or more times, but as few as possible (It matches exactly on row, this is needed because of the ". matches newline" option). The matched row is stored, because of the brackets around and accessible using \1 $ matches the end of the line. \s+?^ this part matches all whitespace characters (newlines!) till the start of the next row ==> This removes the newlines after the matched row, so that no empty row is there after the replacement. (?=.*^\1$) this is a positive lookahead assertion. This is the important part in this regex, a row is only matched (and removed), when there is exactly the same row following somewhere else in the file.
搜索正则表达式:\b(\w+)\b([\w\ w]*)\b\1\b
替换为:$1$2
点击“替换”按钮,直到文件中不再匹配正则表达式为止。
无论文件是否排序,您都可以使用下面的regex删除文件中任何位置的重复项。
^([^\r]*[^\n])(.*?)\r?\ n \ 1美元 替换为:\1\2 搜索模式:
“正则表达式” 检查“。匹配换行"选项
尽可能多地点击“替换全部”(或按住Alt+A快捷键),直到你看到“0次发生被替换”
Notepad + +
->替换window
确保在搜索模式中选择了正则表达式单选按钮
找到:
(*) ^ (r ? (n - 1) +美元
替换为:
$1
之前:
我们认为 我们认为 一行 有可能 有可能
后:
我们认为 一行 有可能
你可能需要一个插件来做到这一点。您可以尝试ConyEdit的命令行cc.ddl(删除重复的行)。它是一个文本编辑器的跨编辑器插件,包括notepad++。
使用ConyEdit在后台运行,遵循以下步骤:
在文本末尾输入命令行cc.ddl。 复制文本和命令行。 粘贴,然后你会看到你想要的。
例子
推荐文章
- 在notepad++中格式化代码
- 我如何使用notepad++(或其他)与msysgit?
- 删除重复的行
- 复制notepad++文本与格式?
- 如何停止notepad++显示文件中所有单词的自动补全
- 如何从c#数组中删除重复项?
- 在SQL Server中查找重复的行
- 在Python Pandas中删除多个列中的所有重复行
- MySQL对重复键更新在一个查询中插入多行
- 我如何检查是否有重复在一个平面列表?
- 如何将大写字母转换为小写notepad++
- 我如何在python中使用熊猫获得所有重复项的列表?
- notepad++是否显示所有隐藏字符?
- 如何在notepad++文本编辑器中更改背景颜色?
- 按列A删除重复项,保留列B中值最高的行