如何使用Notepad ++过滤/正则表达式?

时间:2016-09-05 21:34:15

标签: regex notepad++

我的文本文件包含以下行:

Nmap scan report for 48.168.151.137
Host is up (0.057s latency).
PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 133.41.164.3
Host is up (0.056s latency).
PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 111.40.49.24
Host is up (0.056s latency).
PORT   STATE SERVICE
80/tcp open  http

我想使用notepad ++ regex删除所有文本,只留下带端口的IPS。

例如下面:

48.168.151.137:80
133.41.164.3:80
111.40.49.24:80

我尝试了失败的尝试。请任何人帮助我。

提前谢谢你。 欢呼声。

3 个答案:

答案 0 :(得分:1)

信用证飞向Wiktor Stribizew先生,回答是:

Find: .*?(\d+(?:\.\d+){3})[\s\S]*?\n(\d+)/tcp\h+open\h+http\R*
Replace with: $1:$2\n

答案 1 :(得分:1)

我从维克多的回答中学到了一些东西
并准备了我的第二个答案,完全按预期工作,尝试一下,
查找内容:.+?(\d.+)[\s\S]+?(\d+)/.+[\n]
替换为:$1:$2
下面是解释正则表达式的照片。

enter image description here

答案 2 :(得分:0)

如果你想试试这个正则表达式,它会带来你想要的结果,然后试试这个......

查找:for\s(\d.*)|(\d+)/|.*?

替换:$1$2

但是结果之间会有空格,

48.168.151.137

80

133.41.164.3

80

111.40.49.24

80
下图用于说明... enter image description here

相关问题