Regex Syntax RRS feed

  • Question

  • Looking for some help or confirmation on this syntax to restrict O365 external access. Customer has two ranges of public IPs and we need to get the Regex syntax correct. I will leave out the first 3 octets here, but the ranges are both /24. Therefore the possible ending is 1-255. So, which syntax below captures that? I'm just not sure. 

    Option 1:


    Option 2:


    the reasoning behind Option 2 is as follows:

    Match a digit optionally preceded by a 1 and optionally followed by another digit 1?\d\d? (numbers between 0 and 199), or
    Match a 2 followed by a 0, 1, 2, 3 or 4, which is then followed by a digit 2[0-4]\d (numbers between 200 and 249), or
    Match a 2 followed by a 5 followed by a 0, 1, 2, 3, 4 or 5 25[0-5] (numbers between 250 and 255)

    Thank you for your assistance.

    Tuesday, May 8, 2018 9:27 PM


All replies

  • IP addresses are just strings in the claim pipeline. So you can just look for a string which match the following regex:

    Example: ^1\.2\.3\. would match every IP in the subnet

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    Friday, May 11, 2018 7:53 PM
  • That's a great solution for /24 network. How would you tackle /13 15/ /16 /18 type networks? I'm trying to do this in reverse and block address ranges with those CIDR's. Could Microsoft provide that as a RegEX statement for others to copy and paste ... there are so many ranges

    This is the RegEX code for just two ranges ...


    If I try the above with the ranges below I feel I may hit some kind of limit! (perhaps my brains!) deny from

    Friday, May 18, 2018 2:17 PM