IP v4 Regex for DLP

Viewed 29

I'm trying to create a regex for DLP to detect only certain range of IP addresses (192.168.3.XXX or 192.168.8.XXX).

Regex created

(^|\s)192\.168\.3\.([1-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-4])$

(^|\s)192\.168\.8\.([1-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-4])$

However the detection is not working as expected. Is this the correct regex? Any thoughts?

1 Answers

This should work for you:

^192\.168\.[38]\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])$
Related