如何使用Notepad ++删除文本文件中的所有IP [英] How to remove all ip in a text file with Notepad++

查看:988
本文介绍了如何使用Notepad ++删除文本文件中的所有IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大文本文件,其中包含以下字词:

I have a large text file containing words like this:

12.0.84.130|test|test|United States (US)
12.0.84.131
12.0.84.132

所以我想删除全部来自该文本文件的IP并使它们显示如下:

So i wanted to remove all the IP from that text file and make them appear like this:

12.0.84.130|test|test|United States (US)

如何在Notepad ++中执行此操作?

How can i do this in Notepad++?

推荐答案

您想要删除仅包含IP地址的行,以下是我的工作方式:

You want to delete lines that contain only an IP address, here is how I'd do:


  • Ctrl + H

  • 查找内容: ^ \d +(?:\ 。\ d +){3}(?:\ R | $)

  • 替换为: NOTHING

  • 全部替换

  • Ctrl+H
  • Find what: ^\d+(?:\.\d+){3}(?:\R|$)
  • Replace with: NOTHING
  • Replace all

说明:

^           : begining of line
\d+         : 1 or more digits
(?:         : start non capture group
  \.        : a dot
  \d+       : 1 or more digits
){3}        : end group, repeated 3 times
\R|$        : any kind of line break or end of line

如果您想要更准确地匹配iIP地址,请更改 \d + by (25 [0-5] | 2 [0-4] [0-9] | [01]?[0-9] [0-9]?)(?: \。(?1)){3} 其中(?1)与第1组中的正则表达式相同。

If you want more accurate match for an iIP address, change \d+ by (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?1)){3} where (?1) is the same regex that the one in group 1.


  • Ctrl + H

  • 查找内容: ^(25 [0-5] | 2 [0-4] [0-9] |?[01] [0-9] [0-9])。(?:\( ?1)){3}(?:\ R | $)

  • 替换为: NOTHING

  • 全部替换

  • Ctrl+H
  • Find what: ^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?1)){3}(?:\R|$)
  • Replace with: NOTHING
  • Replace all

这篇关于如何使用Notepad ++删除文本文件中的所有IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆