I’m wanting to keep only the IP addressees in a huge file that look like this using Notepad++ I can’t figure out a good regex to accopmlish this. Any help would be appreciated.

9/9/2099 09:00 PM | UA: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like 
GeckoChrome/34.0.1847.116 Safari/537.36 | IP:
HOST: 61-252-241-65.hlrn.qwest.net | REFERRER: http://www.google.com/

9/9/2099 03:00 PM | UA: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/34.0.1847.116 Safari/537.36 | IP:
HOST: 71-222-254-49.hlrn.qwest.net | REFERRER: http://www.google.com/

Should become


You can use this (check the dotall mode: “. matches newlines”):

find: .*?((?:\d{1,3}\.){3}\d{1,3}\r?\n)|.+
replace: $1

.*? will match all characters until the next IP address (in the group 1)

At the end, when there is no more IP addresses, the first part of the pattern will fail, and .+ takes all the characters until the end. The content of the capture group 1 is preserved.

Thanks to Stackoverflow