如何在 Notepad++ 中搜索并保留一系列重复的单词?

如何在 Notepad++ 中搜索并保留一系列重复的单词?

我有一个长.txt文件,这是一个示例:

A Beautiful Mind (Howard, 2001) Blu-ray, RIP, 1080p, x264, AC3 ITA-ENG, Subs, MKV, 12.26  
A Bigger Splash (Guadagnino, 2015) Blu-ray, RIP, 1080p, x264, DTS ITA, Subs, MKV, 7.93  
A casa con i miei (D. Lee, 2008) WEB, RIP, 1080p, x264, E-AC3/AAC ITA, E-AC3/AAC ENG, Subs, MKV  
A casa con i suoi (Dey, 2006) Blu-ray, RIP, 1080p, x264, AC3 ITA-ENG, Subs, MKV, 8.57  
A casa per le vacanze (Foster, 1995) Blu-ray, FOUND, 1080p, x264, AC3 ITA, MKV, 1.79  
A casa per Natale (Brolin, 2016) WEB, RIP, 1080p, x264, E-AC3 ITA, Subs, MKV, 1.74  
A casa per Natale (Fall, 2013) WEB, MUX, 1080p, x264, AC3 ITA, MKV, 2.68  
A casa per Natale (Sanford, 1998) Blu-ray, MUX, 1080p, x264, AC3 ITA, MKV, 1.73  
A casa tutti bene (Muccino, 2018) Blu-ray, RIP, 1080p, x264, DTS ITA, Subs, MKV, 5.71  
A cavallo della tigre (Comencini, 1961) WEB, RIP, 1080p, x264, AAC/E-AC3 ITA, Subs, MKV, 10.44  
A cena con un cretino (Roach, 2010) Blu-ray, RIP, 1080p, x264, AC3 ITA-ENG, Subs, MKV, 8.36  
A Christmas Carol (Zemeckis, 2009) Blu-ray 3D, Half-SBS, RIP, 1080p, x264, AC3 ITA, AAC ENG, MKV  
A Christmas Carol (Zemeckis, 2009) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV, 4.51  
A Christmas Melody (Carey, 2015) WEB, MUX, 1080p, x264, AC3 ITA, MKV, 1.70  
A Christmas Reunion (Olson, 2015) WEB, MUX, 1080p, x264, AC3 ITA, MKV, 1.75  
A Christmas wish (Clyde , 2011) WEB, RIP, 1080p, x264, AAC ITA, MKV, 1.85  
A Ciambra (Carpignano, 2017) Blu-ray, FOUND, 1080p, x264, DTS ITA, Subs, MKV, 13.39  
A ciascuno il suo (Petri, 1967) Blu-ray, RIP, 1080p, x264, DTS/AAC ITA, AC3 GER, Subs, MKV, 8.82  
A Classic Horror Story (De Feo/Strippoli, 2021) WEB, FOUND, 1080p, x264, E-AC3/AAC ITA, Subs  
A Dangerous Method (Cronenberg, 2011) Blu-ray, RIP, 1080p, x264, DTS ITA, AAC ENG, Subs, MKV  
A Ghost Story (Lowery, 2017) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV, 9.02  
A Good Marriage (Askin, 2014) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV, 7.00  
A History of Violence (Cronenberg, 2005) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV  
À l'intérieur (Bustillo/Maury, 2007) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 FRE, Subs, MKV, 4.61  
A letto con il nemico (Ruben, 1991) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV, 7.44  
A mano disarmata (Bonivento, 2019) Blu-ray, RIP, 1080p, x264, DTS ITA, Subs, MKV, 6.37  
A mezzanotte va la ronda del piacere (Fondato, 1975) DVB, RIP, 1080p, x264, E-AC3/AAC ITA, Subs  
A Modern Family (Fleming, 2018) Blu-ray, RIP, 1080p, x264, DTS ITA, AC3 ENG, Subs, MKV, 6.80  

目的是标记具有相同标题的行,我的意思是如果多于 1 行具有相同的一系列单词(不区分大小写),直到字符),则标记该行。因此,我删除所有未加书签的行,仅保留具有重复标题的行。

可以使用 Notepad++ 正则表达式搜索来完成吗?

任何其他简单的解决方案都值得赞赏。

答案1

  • Ctrl+M
  • 找什么:(^.+?\)).+$(?:\R\1.+$)+
  • 打钩 Bookmark lines
  • 打钩 相符
  • 取消勾选 . matches newline
  • Mark all
  • 搜索菜单 > 书签
  • 删除未标记的行

解释:

(           # group 1
  ^           # beginning of line
    .+?         # 1 or more any character but newline, not greedy
    \)          # closong parenthesis
)           # end group 1
.+          # 1 or more any character but newline
$           # end of line
(?:         # non capture group
    \R          # any kind of linebreak
    \1          # backreference to group 1
    .+          # 1 or more any character but newline
    $           # end of line
)+          # end group, must appear 1 or more times

截屏:

在此处输入图片描述

相关内容