简体   繁体   English

是否有可能在记事本++中循环线?

[英]is it possible to loop lines in notepad++?

I have a txt file with patterned content: 我有一个带有图案内容的txt文件:

Line 1 id=1234
Line 2 id=0001
Line 3 id=4321
Line 4 id=9281
Line 5 id=6631
Line 6 id=1234
Line 7 id=1234
Line 8 id=4321
Line 9 id=7772
Line 10 id=0001
... up to Line 5000 id=6631

I want to replace all repetitive contents (ie. Line 1, 6, 7) to only for the first occur. 我想将所有重复内容(即第1,6,7行)替换为第一次出现。 of content (Line 1 id=1234; 6, 7 removed). 内容(第1行id = 1234; 6,7删除)。 In other words, content id of a line must occur once. 换句话说,行的内容id必须出现一次。 Is that possible though regular expressions? 这可能是正则表达式吗?

Assuming that a line would literally read Line 1 id=1234 : 假设一行按字面意思读取Line 1 id=1234

  • Enter (Line [0-9]+ id=)([0-9]+)(.*?)(Line [0-9]+ id=)\\2\\n into the find box, and \\1\\2\\3 into the replace with box. 在查找框中输入(Line [0-9]+ id=)([0-9]+)(.*?)(Line [0-9]+ id=)\\2\\n ,并输入\\1\\2\\3进入更换盒子。
  • Make sure that Regular Expression is selected and . matches newline 确保选中Regular Expression . matches newline . matches newline is checked. . matches newline被检查。
  • Press Replace All , until all duplicates are removed. Replace All ,直到删除所有重复项。
  • You will see Replace All: 0 occurrence was replaced. 您将看到Replace All: 0 occurrence was replaced. when it's complete. 当它完成。

Assuming instead that the lines would read only id=1234 : 假设这些行只读取id=1234

  • Enter (id=[0-9]+)(.*?)\\1\\n into the find box, and \\1\\2 into the replace with box. 在查找框中输入(id=[0-9]+)(.*?)\\1\\n ,在替换为框中输入\\1\\2
  • Make sure that Regular Expression is selected and . matches newline 确保选中Regular Expression . matches newline . matches newline is checked. . matches newline被检查。
  • Press Replace All , until all duplicates are removed. Replace All ,直到删除所有重复项。
  • You will see Replace All: 0 occurrence was replaced. 您将看到Replace All: 0 occurrence was replaced. when it's complete. 当它完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM