samedi 14 décembre 2019

Excluding specific values from pattern match

The following regex captures IP addresses as well as DNS hostnames. What I'd like is to add some IPs to ignore, such as 1.0.0.0 and 0.0.0.0 for example. I tried some negative lookahead without success.

[\w-]+(\.[\w-]+)+

for example :

www.google.com 255.255.255.255 1.0.0.0 stackoverflow.com 0.0.0.0

should match 3 out of 5 in that line

Any tips would be great.

Aucun commentaire:

Enregistrer un commentaire