Search code examples
regexnotepad++

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.


Solution

  • 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