I would like to negate this regex that matches if the ip is 220.127.116.11 and followed by 'myhost' but i want it to match if the ip is not 18.104.22.168 but it is followed by myhost
I tried doing this but it does not work.
I also would like to negate this regex that matches the hostname but I would like to match if the hostname is not "myhost"
the regex matches myhost if its preceeded by 22.214.171.124
the idea is to check some /etc/hosts files and make sure the ip matches the hostname and viceverza.. I will be doing this in ansible.. so if the regex can be combined in one line..
in a nutshell i want to test that are always correct. I am using ansible fact to find the ip and hostname.. i have just problem with the regexes.
edit: as requested some examples:
i have the following 4 lines:
126.96.36.199 hostname (1) 188.8.131.52 hostname (2) 184.108.40.206 otherhost (3) 220.127.116.11 otherhost (4)
line (1) nothing should match.
in lines (2) it should match the ip address but without the espace after it.
in line (3)
otherhost should match.
In line (4) both should match..
If any of the regex match it will be replaced with ansible with line (1) this is to make sure the /etc/host is correct. does not have typos or inconsistencies.