Notepad++ 删除记事本中某些字符之前的所有内容++;

Notepad++ 删除记事本中某些字符之前的所有内容++;,notepad++,Notepad++,如何删除本文中第6个冒号之前的所有内容,例如: 123:::12423:122343:123:1234:example 1212d3:::123:123453:12333:12345:example 12dd3:::12663:1223423:123:123456:example 123:::123:123:123:1234567:example 124tsd3:::121233:123:123:12346578:example 125sdf3:::123:1254353:123:1234567

如何删除本文中第6个冒号之前的所有内容,例如:

123:::12423:122343:123:1234:example
1212d3:::123:123453:12333:12345:example
12dd3:::12663:1223423:123:123456:example
123:::123:123:123:1234567:example
124tsd3:::121233:123:123:12346578:example
125sdf3:::123:1254353:123:123456789:example
那么我就剩下:

1234:example
12345:example
123456:example
1234567:example
12346578:example
123456789:example

您可以使用此正则表达式:
*?(\d+:示例)
,并将其替换为
$1

有关此正则表达式的说明,请参见


如果要处理数字和单词以外的其他字符串,请执行以下示例:

  • Ctrl+H
  • 查找内容:
    ^.+:(?=[^::+:[^:::+:[^:::+$)
  • 替换为:
    EMPTY
  • 全部替换
说明:

^           : begining of line
.+          : 1 or more any character
:           : literally :
(?=         : start lookahead, make sure we have the following after
  [^:]+     : 1 or more any character but :
  :         : literally :
  [^:]+     : 1 or more any character but :
  $         : end of line
)           : end lookahead
1234:example
12345:example
123456:example
1234567:example
12346578:example
123456789:example
不要选中
。匹配换行符

给定示例的结果:

^           : begining of line
.+          : 1 or more any character
:           : literally :
(?=         : start lookahead, make sure we have the following after
  [^:]+     : 1 or more any character but :
  :         : literally :
  [^:]+     : 1 or more any character but :
  $         : end of line
)           : end lookahead
1234:example
12345:example
123456:example
1234567:example
12346578:example
123456789:example

投赞成票!,喜欢对正则表达式逐行解释。@PaulT:谢谢