Search code examples
regexnotepad++

How to delete everything before and after the ip address and port?


I am wondering how to delete everything before and after the IP address and port in Notepad++. For example, from this:

email:pass | ip = 139.224.45.151 | port = 8080 | protocol = http | country = CN
email:pass | ip = 102.67.68.1 | port = 1080 | protocol = socks4 | country = ZZ
email:pass | ip = 94.54.211.197 | port = 80 | protocol = http | country = TR
email:pass | ip = 161.97.138.241 | port = 3128 | protocol = http | country = US

..to this

139.224.45.151:8080
102.67.68.1:1080
94.54.211.197:80
161.97.138.241:3128

Solution

    • find what: ^.* ip = *([\d\.]*).* port = *(\d*).*$
    • replace with: $1:$2
    • (o) regular expression checked, [_] , matches newline unchecked