DX Unified Infrastructure Management

  • 1.  REG-EX help

    Posted Sep 15, 2014 06:28 PM

    Any help on the following regular expression would be much appreciated. It was working until about a month ago.

     

    Trying to match: (just listed one interface but you can see the additional matches that are required)

     

    Interface-Down IF-198.151.49.30/391 [Se0/1/3:23] [187]

     

    My regex:

    /.*Interface-Down\sIF-*.*.*.*./%d[Se][0-9]|.*Interface-Down\sIF-*.*.*.*./%d[T][0-9]|.*Interface-Down\sIF-*.*.*.*./%d[Hs][0-9]|.*Interface-Down\sIF-*.*.*.*./%d[ATM][0-9]|.*Interface-Down\sIF-*.*.*.*./%d[E][0-9]*/

     

     

    Thank you



  • 2.  Re: REG-EX help

    Posted Sep 16, 2014 02:03 AM
    I'd suggest

    /.*Interface-Down\sIF-[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]*\s\[Se[0-9]/

    to match the example. Others will be similar.

    regexpal.com has a really nice tool for testing expressions too.
    -Garin


  • 3.  Re: REG-EX help

    Posted Sep 16, 2014 06:25 AM

    Garin,

     

    Thank you I will try it out.



  • 4.  Re: REG-EX help

    Posted Sep 16, 2014 09:46 AM

    Also, from your original regex:

     

    /.*Interface-Down\sIF-*.*.*.*./

     

    #1: There is no need for the leading .* since you don't have a ^

    #2: the *.*.*.*. is not probably not what you want to do? Unless you mean 0 or more - ? Should probably be .*.*.*.* but that doesn't make any sense either, unless you do .*\..*\..*\..*

    #3: That random / in the middle is just gonna break stuff unless you escape it. The way it is now, it's gonna stop your expression there.

    #4: Repeat..

     

    May I also recommend a regex cheat sheet? Something like this.