Ad Widget

Collapse

Filesystem discovery RegEx Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muelli
    Member
    • Jun 2021
    • 68

    #1

    Filesystem discovery RegEx Problem

    Hello forum,

    I have a problem with a custom filesystem discovery RegEx.
    Filesystems are like this:

    1)
    /application/something/else

    2)
    /application/something/unwanted/else


    My regex so far is ^(application.+) which matches 1+2. But I do NOT want 2 to match.
    So far I could not find a regex that matches 1 but does NOT match 2.

    Does someone have a hint on a fitting regex?
    Thanks!
  • nuri
    Junior Member
    • Jan 2015
    • 14

    #2
    Dear Zabbixian Friend,

    I am very new to REGEX.
    I have made a guess as of below;
    Hope this will help ....

    \/application(?!(\/something\/unwanted\/else))

    https://regex101.com/r/puCpMK/1


    Regards,

    Nuri.

    Comment

    • muelli
      Member
      • Jun 2021
      • 68

      #3
      Thanks for the tip, actually the "something" part is dynamic as well :/

      more like this
      /application/XYZ/unwanted/other/parts
      where XYZ is 3 characters always.

      Comment

      • nuri
        Junior Member
        • Jan 2015
        • 14

        #4
        Hello,

        Try this >>> \/application(?!(\/\w{9}\/unwanted\/else))

        Comment

        • nuri
          Junior Member
          • Jan 2015
          • 14

          #5
          Hello,

          Or try that >>> \/application(?!(\/\w{3}\/unwanted\/else))​

          Comment

          • muelli
            Member
            • Jun 2021
            • 68

            #6
            Hm, the first one does not match anything, the second one matches both....
            It is tricky....maybe this cannot be solved via regex at all.....

            I came up with this:

            ^\/application\/.{3}\/(?!(unwanted))

            This part: ^\/application\/.{3}\/
            should match /application/XYZ/
            now all I must figure out is to append something like a "AND NOT 'unwanted'"
            Last edited by muelli; 12-07-2023, 13:05.

            Comment

            • nuri
              Junior Member
              • Jan 2015
              • 14

              #7
              Hello,

              https://regex101.com/r/xjLW4y/1


              Click image for larger version

Name:	image.png
Views:	106
Size:	22.0 KB
ID:	467135

              something >>> 9 characters.

              Comment

              • muelli
                Member
                • Jun 2021
                • 68

                #8
                THats it, works in regex tester, now I will put it into zabbix!
                Thanks for your help!

                Comment

                • nuri
                  Junior Member
                  • Jan 2015
                  • 14

                  #9
                  Nice to hear you are happy with that.

                  Comment

                  Working...