Discontiguous IP ranges in one device group


I have several blocks of IP space that I’m looking to create an application for. To begin I’m trying to dynamically grab the devices in a single device group

I know there’s gotta be a regex answer but every time I’ve built one it drops from almost 300 devices known back to zero.


Did you really mean /23 on the subnet - as I believe that would overlap with the


Ahh yes, I was typing a bit fast. It’s 10.200.41-44, so I meant 41.0/24, 42.0/23, and 44.0/24


Assuming you meant /24 on the subnet, I have been playing around with this REGEX puzzle and although I’m not a REGEX guru I think I come up with something that will work:

I tested it at regexr.com and it seemed to match your ranges. It’s not pretty and probably not optimized for production, but it seems to work.


So, it seems we’re looking for this:

10.200.41-44, so I meant 41.0/24, 42.0/23, and 44.0/24

That would be:



/    -- start of regex
^    -- match start of IP address
10   -- literal number `10`
\.   -- match a period
200  -- literal number `200`
\.   -- another period
4    -- literal number `4`
[1-4] -- match numbers `1` through `4` inclusive
\.   -- literal period
/    -- end of regex

Let us know if it works.


With the string /^10.(102.\d|1[0-5]|200.4[1-4])./

I seem to get the 10.200.41-44.0 alright, and the 10.102.0-9 comes in correctly, but I’m missing some responses in the 10-15 3rd octet


Final Answer:

It didn’t seem to like the truncation in OR 1 OR 2 with OR 3 having the second and third octets change. It works, thanks all!