我想通过记事本++删除多个输入

时间:2014-01-23 02:25:56

标签: notepad++

我有这个正则表达式

替换此

^(\ d +。\ d +。\ d +。\ d +)(。+)\ r \ n(\ 1。+ \ r \ n)*

\ 1 \ 2 \ r \ n

这是结果

替换此

109.172.14.61 : 1 : 1
109.172.14.61 : 1 : 8888
109.172.14.61 : 2 : 1234
109.172.14.61 : 2 : 8888
109.172.60.153 : 73 : 73
109.188.66.153 : 11 : 0000
109.188.66.153 : 11 : 123456
109.188.83.137 : 2010 : 22222

到这个

109.172.14.61 : 1 : 1
109.172.60.153 : 73 : 73
109.188.83.137 : 2010 : 22222

但我需要另一个结果

我想要这个

109.172.14.61 : 1 : 1
109.172.14.61 : 1 : 8888
109.172.14.61 : 2 : 1234
109.172.14.61 : 2 : 8888
109.172.60.153 : 73 : 73
109.188.66.153 : 11 : 0000
109.188.66.153 : 11 : 123456
109.188.83.137 : 2010 : 22222

到这个

109.172.14.61 : 1 : 1
109.172.14.61 : 2 : 1234
109.172.60.153 : 73 : 73
109.188.66.153 : 11 : 0000
109.188.83.137 : 2010 : 22222

任何帮助请!!

2 个答案:

答案 0 :(得分:0)

尝试此操作,因为后缀编号是唯一可以检查字符串是否应删除或替换的编号:

(\ d {1,3})。{4} \ S:\ S \ d {1,2} \ S:\ S(8888 | 123456)

答案 1 :(得分:0)

尝试使用:

找到:^(\d+(?:\.\d+){3}\s+:\s+\d+)(.+?)\R(?:\1.+?\R)*
替换为:$1$2\r\n

<强>解释

^           : start line
(           : begin capture group 1
  \d+       : 1 or more digits
  (?:       : begin NON capture group
    \.      : a dot
    \d+     : 1 or more digits
  ){3}      : non capture group repeated 3 times
  \s+       : 1 or more space
  :         : semi-colon
  \s+       : 1 or more space
  \d+       : 1 or more digits
)           : end of group 1
(           : begin group 2
  .+?       : 1 or more any character but newline non greedy
)           : end group 2
\R          : any kind of line break (\n or \r\n or \r)
(?:         : begin non capture group
  \1        : same content as group 1
  .+?       : 1 or more any character but newline non greedy
  \R        : any kind of line break (\n or \r\n or \r)
)*          : non capture group repeated 0 or more times.