首页 > 解决方案 > 如何在记事本++中选择这些IP地址

问题描述

我在文本文件中有这些 IP 地址:

123.456.789.987 |     0x (8B -> 0B)     |N/A
756.789.412.478 |     0x (8B -> 0B)     |N/A
321.745.748.415 |     0x (8B -> 0B)     |N/A
14.48.210.33 |     6x (8B -> 48B)     |N/A
42.117.63.132 |     6x (8B -> 48B)     |N/A
2.6.133.228 |     6x (8B -> 48B)     |N/A

我只需要选择所有IP地址123.456.789.987 | 0x (8B -> 0B) |N/A

我需要完整的行,用空行替换,以这种方式留下 IP 地址:

14.48.210.33 |     6x (8B -> 48B)     |N/A
42.117.63.132 |     6x (8B -> 48B)     |N/A
2.6.133.228 |     6x (8B -> 48B)     |N/A

标签: notepad++

解决方案


不确定要保留的 IP,但这会产生您的预期结果:

  • Ctrl+H
  • 找什么:^.+0x\h+\(8B\h+->\h+0B\).+\R
  • 用。。。来代替:LEAVE EMPTY
  • 取消选中匹配案例
  • 检查环绕
  • 检查正则表达式
  • 不要检查. matches newline
  • Replace all

解释:

^           # beginning of line
  .+        # 1 or more any character
  0x        # literally 0x
  \h+       # 1 or more horizontal spaces
  \(        # opening parenthese
  8B        # literally 8B
  \h+       # 1 or more horizontal spaces
  ->        # literally ->
  \h+       # 1 or more horizontal spaces
  0B        # literally 0B
  \)        # closing parenthese
  .+        # 1 or more any character
  \R        # any kind of linebreak (ie. \r, \n, \r\n)

给定示例的结果:

14.48.210.33 |     6x (8B -> 48B)     |N/A
42.117.63.132 |     6x (8B -> 48B)     |N/A
2.6.133.228 |     6x (8B -> 48B)     |N/A

推荐阅读