I want regex to find IP address which not starts with 220.127.116.11.
I have written some regex
. in a regex is character that matches everything. To use it in this context, you must escape it.
Also to limit it to just ip addresses that start with 172, simply hardcode it into your regex like so:
You could then use this to filter out any matches already made.
Alternatively, if you're not starting with a list of ip addresses, you could use a negative look-ahead to grab them all straight away.
Be a little careful in that this may match more than ip addresses - for example
400.660.226.602 would be captured - even though real IP4 addresses do not contain numbers higher than
255. Perhaps this won't affect your use case - but it's something to remember.
As per the comments below, if you are searching for IP addresses anywhere in the document, rather than on their own line, use
\b instead of
This would match log formats for example, which contain an ip address within the message rather than on it's own line.
[10:01:22] Connection from