Today, one of my costumers asked me to create some groups and Live Maps views containing network devices with a specific ip address range. Now, im a big fan of the “work smarter, not harder” principle, so I wanted the groups and views to be dynamic using regular expressions.

I’ve worked with regular expressions before, which is fairly manageable with a table of the meta characters on your hand. However, I find ip addresses a lot more tricky, which is why I’m posting different solutions.

Before advancing, I would like to introduce you to a dear friend of mine: On you can test your regular expressions to make sure they are working.

All possible ip addresses:


Yes, this looks pretty complicated, but I’m going to break it down in some examples.


Example 1: you want all the ip addresses with an XXX.50.XXX.XXX address:




Example 2: you want all the ip addresses with an XXX.XXX.2.1 address:



Example 3: you want ip addresses between the second octets and (10.10.X.X and 10.20.X.X):

^(\d|10)\.(\d|1\d|1\d\d|2([0-9]\d|5[0-9]))\.(10)\.(1)$ = everything between and ^(\d|10)\.(20)\.(10)\.(1)$ =, but not



Example 4: Ip addresses starting with 10:



Example 5:  Ip addresses starting with 192.168.100



Using these examples and its a lot easier to make a regular expression. Let me know if you need other examples 🙂


Happy regular expressioning!