mza box
mza box

Reputation: 67

How to filter/regex with Notepad++?

I have a textfile contains lines with below:

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

I want to use notepad++ regex to remove all texts and just leave the IPS with port.

For example below:

48.168.151.137:80
133.41.164.3:80
111.40.49.24:80

I've tried my best with failed attempts. Kindly can anybody help me out.

Thank you in advance. Cheers.

Upvotes: 0

Views: 3798

Answers (3)

Haji Rahmatullah
Haji Rahmatullah

Reputation: 430

I learnt something from viktor's answer
and prepared my second answer, completely working as intended, try it,
Find what: .+?(\d.+)[\s\S]+?(\d+)/.+[\n]
Replace with: $1:$2
Below is photo for explanation of regex.

enter image description here

Upvotes: 1

Haji Rahmatullah
Haji Rahmatullah

Reputation: 430

If you want to try this regex, it will bring the same result as desired then try this ....

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

Replace: $1$2

But there will be spaces in between results ,

48.168.151.137

80

133.41.164.3

80

111.40.49.24

80
The below picture is used for explanation... enter image description here

Upvotes: 0

mza box
mza box

Reputation: 67

Credit flys to Mr. Wiktor Stribizew, answer is:

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

Upvotes: 1

Related Questions