Notepad++ // 如何删除特定文本字符串之间的所有内容,包括字符串本身?

Notepad++ // 如何删除特定文本字符串之间的所有内容,包括字符串本身?

以下示例全部在一行中,我遇到了大量此类问题,我想修复这些问题。我想删除重复的文件路径。每行的第一个文件路径都是单个文件,但之后的每个文件路径后面都跟有"><img src="RepeatOfThePath" class="_2yuc _3-96" />

"><img src="我想要删除的只是和之间的部分" class="_2yuc _3-96" />(包括那些字符串),但不需要一直执行命令到行尾,因为那是日期所在的位置(应该保持在原位)。

前:

User Two||User Two sent 8 photos. File locations: Messaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49450603_219138382307432_3277446984746663936_n_219138378974099.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49764923_358739138271625_580785213139845120_n_358739134938292.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/49764923_358739138271625_580785213139845120_n_358739134938292.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/48404864_921427388047408_7300876900581244928_n_921427381380742.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/48404864_921427388047408_7300876900581244928_n_921427381380742.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49164579_214366476179977_4468743459502555136_n_214366469513311.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/49164579_214366476179977_4468743459502555136_n_214366469513311.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49787371_2255721791336152_3381788336120135680_n_2255721784669486.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/49787371_2255721791336152_3381788336120135680_n_2255721784669486.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/48985330_811888555823956_4821470710998237184_n_811888549157290.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/48985330_811888555823956_4821470710998237184_n_811888549157290.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49658202_599404630515667_5325374562135703552_n_599404627182334.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/49658202_599404630515667_5325374562135703552_n_599404627182334.jpg" class="_2yuc _3-96" />LnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49021071_212456299699526_956147449091588096_n_212456293032860.jpg"><img src="messages/inbox/UserOne_iW_GxLYs3A/photos/49021071_212456299699526_956147449091588096_n_212456293032860.jpg" class="_2yuc _3-96" />||Dec 30, 2018, 10:29 AM

后:

User Two||User Two sent 8 photos. File locations: Messaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49450603_219138382307432_3277446984746663936_n_219138378974099.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49764923_358739138271625_580785213139845120_n_358739134938292.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/48404864_921427388047408_7300876900581244928_n_921427381380742.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49164579_214366476179977_4468743459502555136_n_214366469513311.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49787371_2255721791336152_3381788336120135680_n_2255721784669486.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/48985330_811888555823956_4821470710998237184_n_811888549157290.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49658202_599404630515667_5325374562135703552_n_599404627182334.jpgLnBrkMessaging Archive/messages/inbox/UserOne_iW_GxLYs3A/photos/49021071_212456299699526_956147449091588096_n_212456293032860.jpg||Dec 30, 2018, 10:29 AM

我应该怎么办?

答案1

  • Ctrl+H
  • 找什么:"><img\h+.+?class="_2yuc _3-96" />
  • 用。。。来代替:LEAVE EMPTY
  • 取消勾选匹配大小写
  • 检查环绕
  • 检查正则表达式
  • 取消选中. matches newline
  • Replace all

解释:

"><img                  # literally
\h+                     # 1 or more horizontal spaces
.+?                     # 1 or more any character but newline
class="_2yuc _3-96" />  # literally

屏幕截图:

在此处输入图片描述

相关内容