本文翻译自:Removing duplicate rows in Notepad++

是否可以在Notepad ++中删除重复的行,而只留下一行?


#1楼

参考:https://stackoom.com/question/GbkM/在记事本-中删除重复的行


#2楼

The latter versions of Notepad++ do not apparently include the TextFX plugin at all. 后来的Notepad ++版本显然根本不包含TextFX插件。 In order to use the plugin for sorting/eliminating duplicates, the plugin must be either downloaded and installed (more involved) or added using the plugin manager. 为了使用该插件对重复项进行排序/消除,必须下载并安装该插件(涉及更多)或使用插件管理器添加该插件。

A) Easy way (as described here ). A)简单的方法(如描述在这里 )。

Plugins -> Plugin Manager -> Show Plugin Manager -> Available tab -> TextFX Characters -> Install 插件->插件管理器->显示插件管理器->可用选项卡-> TextFX字符->安装

B) More involved way, if another version is needed or the easy way does not work. B)如果需要另一个版本或简单方法不起作用,则采用更多的参与方式。

  1. Download the plugin from SourceForge: 从SourceForge下载插件:

    http://downloads.sourceforge.net/project/npp-plugins/TextFX/TextFX%20v0.26/TextFX.v0.26.unicode.bin.zip http://downloads.sourceforge.net/project/npp-plugins/TextFX/TextFX%20v0.26/TextFX.v0.26.unicode.bin.zip

  2. Open the zip file and extract NppTextFX.dll 打开压缩文件并解压缩NppTextFX.dll

  3. Place NppTextFX.dll in the Notepad++ plugins directory, such as: NppTextFX.dll放在Notepad ++插件目录中,例如:
    C:\\Program Files\\Notepad++\\plugins C:\\ Program Files \\ Notepad ++ \\ plugins

  4. Start Notepad++, and TextFX will be one of the file menu items (as seen in Answer #1 above by Colin Pickard) 启动Notepad ++,TextFX将成为文件菜单项之一(如上述Colin Pickard的答案#1所示)

After installing the TextFX plugin, follow the instructions in Answer #1 to sort and remove duplicates. 安装TextFX插件后,请按照答案1中的说明进行排序并删除重复项。

Also, consider setting up a keyboard shortcut using Settings > Shorcut mapper if you use this command frequently or want to replicate a keyboard shortcut, such as F9 in TextPad for sorting. 另外,如果您经常使用此命令,或者想复制键盘快捷键(例如TextPad中的F9)进行排序,请考虑使用“设置”>“ Shorcut映射器”来设置键盘快捷键。


#3楼

Since Notepad++ Version 6 you can use this regex in the search and replace dialogue: 从Notepad ++版本6开始,您可以在搜索和替换对话框中使用此正则表达式:

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

and replace with nothing . 一无所获 。 This leaves from all duplicate rows the last occurrence in the file. 这将使所有重复的行中文件中的最后一次出现。

No sorting is needed for that and the duplicate rows can be anywhere in the file! 无需排序,重复的行可以在文件中的任何位置!

You need to check the options "Regular expression" and ". matches newline": 您需要检查选项“正则表达式”和“。匹配换行符”:

  • ^ 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). (.*?)匹配任何字符0次或多次,但应尽可能少(它与行完全匹配,这是必需的,因为“ .matches newline”选项)。 The matched row is stored, because of the brackets around and accessible using \\1 之所以存储匹配的行,是因为方括号括起来并且可以使用\\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 matchd row, so that no empty row is there after the replacement. \\s+?^这部分匹配所有空格字符(换行!),直到下一行的开始==>这将删除匹配行之后的换行符,以便替换后没有空行。

  • (?=.*^\\1$) this is a positive lookahead assertion. (?=.*^\\1$)这是一个肯定的超前断言。 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. 这是此正则表达式中的重要部分,当文件中其他位置后面紧随同一行时,仅匹配(并删除)一行。


#4楼

Search for the regular expression: \\b(\\w+)\\b([\\w\\W]*)\\b\\1\\b 搜索正则表达式: \\b(\\w+)\\b([\\w\\W]*)\\b\\1\\b

Replace it with: $1$2 替换为: $1$2

Hit the Replace button until there are no more matches for the regular expression in your file. 点击替换按钮,直到文件中的正则表达式不再匹配。


#5楼

None worked for me. 没有人为我工作。

A solution is: 一个解决方案是:

Replace 更换

^(.*)\s+(\r?\n\1\s+)+$

with

\1

#6楼

If you don't care about row order (which I don't think you do), then you can use a Linux/FreeBSD/Mac OS X/Cygwin box and do: 如果您不关心行顺序(我不认为这样做),则可以使用Linux / FreeBSD / Mac OS X / Cygwin框并执行以下操作:

$ cat yourfile | sort | uniq > yourfile_nodups

Then open the file again in Notepad++. 然后在Notepad ++中再次打开文件。

在记事本++中删除重复的行相关推荐

  1. textarea选中行删除_Easy Data Transform如何在Excel中删除重复的行?

    Excel用户经常希望删除具有重复值的行.例如,要删除包含重复电子邮件的行,那么Easy Data Transform如何在Excel中删除重复的行?下面一起来看看吧. 先在您的Mac上安装Easy ...

  2. 在MySQL中删除重复的行

    本文翻译自:Remove duplicate rows in MySQL I have a table with the following fields: 我有一个包含以下字段的表: id (Uni ...

  3. Access中删除重复数据行

    1.什么是重复数据行: 1>.两笔记录的每一个字段都相同(表中没有主键): 2>.两笔记录的特定字段均相同,其余字段不同(表中可能有主键,也可能没有主键): 2.如何删除重复数据行: 1& ...

  4. SQL中删除重复的行(重复数据),只保留一行 转

    方法一:使用在T-SQL的编程中 分配一个列号码,以COL1,COL2组合来分区排序,删除DATABASE重复的行(重复数据),只保留一行 // COL1,COL2是数据库DATABASE的栏位 de ...

  5. mysql 如何删除重复的行_如何从mysql中的表中删除重复的行

    我需要从 mysql中删除表中的重复记录. 所以我有一个表名"employee"字段是empid,empname,empssn 为了获得重复记录我写了一个查询 SELECT COU ...

  6. sql删除表中重复记录_SQL从SQL表中删除重复行的不同方法

    sql删除表中重复记录 This article explains the process of performing SQL delete activity for duplicate rows f ...

  7. R语言unique函数计算数据对象(vector、dataframe)的unique独特值:unique函数从vector向量、dataframe中删除重复项、删除dataframe重复行

    R语言unique函数计算数据对象(vector.dataframe)的unique独特值:unique函数从vector向量.dataframe中删除重复项.删除dataframe重复行 目录

  8. pandas删除数据行中的重复数据行、基于dataframe所有列删除重复行、基于特定数据列或者列的作何删除重复行、删除重复行并保留重复行中的最后一行、pandas删除所有重复行(不进行数据保留)

    pandas删除数据行中的重复数据行.基于dataframe所有列删除重复行.基于特定数据列或者列的作何删除重复行.删除重复行并保留重复行中的最后一行.pandas删除所有重复行(不进行数据保留) 目 ...

  9. 温故知新MySQL--如何在MySQL表中删除重复行

    2019独角兽企业重金招聘Python工程师标准>>> 如何在MySQL表中删除重复行 在实际应用中,会有需要删除重复数据的场景.这里简单介绍下如何删除重复的数据 1. 准备数据 C ...

最新文章

  1. python 遍历文件夹和文件
  2. WINDOWS 几种坐标系
  3. JS 面向对象实例 prototype
  4. BBC英语-drama
  5. [转]Spring注解-@Configuration注解、@Bean注解以及配置自动扫描、bean作用域
  6. android天气时钟课程设计报告,安卓课程设计报告--《基于网络返参的安卓天气预测分析》...
  7. 【渝粤教育】国家开放大学2018年春季 8662-22T特色课(1) 参考试题
  8. SPSS 分层回归(图文+数据集)【SPSS 027期】
  9. HDU 4278 卡特兰,区间DP
  10. 蚂蚁区块链第17课 错误码指导大全
  11. [已实现]暴力破解路由器管理密码
  12. 染布厂ERP、染厂ERP、漂染厂ERP、纺织印染ERP生产管理系统
  13. 洛谷P1548 [NOIP1997 普及组] 棋盘问题
  14. 阿里投资分众,大战在即的电梯广告市场却有本糊涂账?
  15. html实现给微信发红包看照片,微信发红包看图片效果实现
  16. 百度地图、高德地图、腾讯地图比较
  17. 使用 SimpleWebRTC 构建 WebRTC 视频聊天应用程序
  18. 推荐系统-推荐引擎的架构
  19. linux c 内存elf,关于LINUX下的可执行程序ELF(一)
  20. DFMEA之严重度/频度/探测度/风险优先系数

热门文章

  1. CLOSE_WAIT状态的原因与解决方法(2)
  2. SQL SERVER 2012 执行计划走嵌套循环导致性能问题的案例
  3. centos 下安装 mysql 5.6
  4. hdu 2255+hdu 3395
  5. 两分钟学会Android平台NDK编程(无须Eclipse和cygwin,可使用命令行打包多个so)
  6. java--基本数据类型的转换(强制转换)
  7. 多表查询,初识pymysql模块
  8. 自动化测试元素查找利器firepath介绍
  9. java单例模式使用及注意事项
  10. windows下文件系统格式介绍