I have a large text file containing words like this:
12.0.84.130|test|test|United States (US)
12.0.84.131
12.0.84.132
So i wanted to remove all the IP from that text file and make them appear like this:
12.0.84.130|test|test|United States (US)
How can i do this in Notepad++?
Use Regex in Notepad++ Replace and search by Find what: (^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$) Replace: \1 |test|test|United States (US)
Dont forget to check Regular Expression in Notepad++ :)
You want to delete lines that contain only an IP address, here is how I'd do:
^\d+(?:\.\d+){3}(?:\R|$)
NOTHING
Explanation:
If you want more accurate match for an iIP address, change
\d+
by(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?1)){3}
where(?1)
is the same regex that the one in group 1.^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?1)){3}(?:\R|$)
NOTHING
In my experience the following works best to match and replace an exact IP address:
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
NOTHING
If you only want to remove IP's that contain new lines after them (Exactly like your before and after in the question) use:
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)([\r\n]+)
(Keep in mind when testing with your example 12.0.84.132 was left over because there is no newline after 12.0.84.132 when copying and pasting)