2 Replies Latest reply on Oct 23, 2013 8:24 PM by njoylif

    Regular Expressions for Dynamic Query on NPM

    gigabyte

      I am creating dynamic queries on NPM for sites to fall in their respective groups. I would like to know correct expression to include these subnet's in the queries.

       

      So let’s consider that I have a site with /27 subnet 10.10.10.0/27, which will have a valid rage between 10.10.10.1-30.

      What kind of expression will match the range of  IP’s in the query given below.

       

      We have used similar expression “ 10.10.[0-3].* ” for matching the 3 octet of the subnet but it only matches " 10.10.0.X "

      Similarly when I am matching the last octet  ex : 10.10.10.[10-20]

       

      So the match case only matches the first digit inside the bracket and skips the rest

       

      Dynamic query.png

        • Re: Regular Expressions for Dynamic Query on NPM
          gigabyte

          So here is the deal !

          I spoke with support tech they told me that they don't fully support regular expression.

          What I figured out is that when we enter regular expression while building dynamic queries, Orion considers numbers in an IP as characters and will match only one character at a time.

           

          Let's take couple of range of IP's to work with.

                       IPs                                         Regular Expression                                                                                                                                                                         

          1: 10.30.0.1 - 10.30.3.254 :                      10.30.[0-3].*          

           

          2: 10.30.42.1 - 10.30.49.254 :                  10.30.4[2-9].*        

          Since it does the charcter matching, we have fixed the first character of the 3rd octet as 4 and the 2nd charcter between 2-9

           

          3: 10.30.156.1 - 10.30.159.254 :               10.30.15[6-9].*      

          Here first 2 characters in the 3rd octet is fixed.

           

          Note: This whole logic works as long as there is no reset in the character of the octet that you are matching, the reason for which I will clear in the following example.

           

          4:  10.30.68.1 - 10.30.71.254    :              10.30.6[8-9].* & 10.30.7[0-1].*

          In this example since the 1st character of the 3rd Octet is getting reset, you need two separate queries to cover the whole range.

           

          5:  10.254.109.209-10.254.109.222 :         10.254.109.209, 10.254.109.21[0-9] , 10.254.109.22[0-2]

          Here you will need 3 separate queries to split and match the complete range

           

          I hope that helps,
          Open for suggestions if you have any other alternatives.

          1 of 1 people found this helpful