I’m writing a regex for google analytics and I need to block any IP from 156.21.x.x I don’t care about the last 2 octets just the first two. I would like to keep the regex to as few characters as possible as google only allows 255 chars and my regex is already pretty large.
Share
not sure what flavor of regex or what lang your using, but this will work on most regex engines:
Of course, this will match invalid ip’s like 156.21.777.888, but if the list your parsing doesnt contain invalid ip addresses, then you should be ok. Or: