There is a text with IP addresses on each line as well arbitrary ones with digits/dots. How can I match only lines that are not IP addresses?
10.123.34.12
asdADSas 3242 .
10.123.34.12
Empty lines are OK.
How do I solve this problem?
There is a text with IP addresses on each line as well arbitrary ones with digits/dots. How can I match only lines that are not IP addresses?
10.123.34.12
asdADSas 3242 .
10.123.34.12
Empty lines are OK.
How do I solve this problem?
While looking for NOT things is something RegEx can do, it's not something that it should do. Look-aheads can be much slower than just checking each line for a match and copying that match to another array/list/string. Depending on the accompanying language this could bottleneck your process.
That being said the RegEx you are looking for is:
^((?!\b((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:(?<!\.)\b|\.)){4}).)*$
You could also modify this to allow empty lines if you want.