9/24/2015

BGP Regular Expression hints


RegEX:
    ^    Matches the beginning of input.
    $    matches the end of input
    | (pipe)    A logical "or" statement.
    . (period) matches a SINGLE character.
    +    matches the character to the left 1 or more times.
    *    matches the character to the left 0 or more times.
    ?    matches the character to the left 0 or 1 times.
    \    removes special meanings.
    ( )    affects order of operations
    [ ]    creates a group of characters.
    _   white space.

Examples:
    150.1.1.0/24
    AS Path: 6733 982 43 239 852 4439 10295 6010 10

1. only match 43:    _43_
2. only match 43 or 10:    _43_|_10_
3. only match the last previous 6733: ^6733  ---begins with 6733, it reads left to right.
4. only match AS originated 10:        _10$  --match end of the string, which is 10 orginated AS.

    (_33_|_44_)_982_
        match EITHER 33 OR 44 FOLLOW BY 982.
   
    ^6733_.  ====matches most recent AS and anything behind, but not originated from 6733. The period is 1 charater, so matches any AS, no matter how many, after 6733, since 1 character after.
   
    ^[0-9]+$ ====match to the left of + one or more times. just match one AS.
    [300]+ === match 300 one or more times.

AS 300 300 300 300
    to match 300 again and again:   
        ^(300)+$

        $([0-9]+)(_\1)*$ ===0-9 one or more times. AS 1234, 555, etc.  To match ANY AS that has been prepended.       
       
5.  Match stuff originated from my AS. Match internal routes only.  Inside our AS.  Only when leaves our AS, do we put the AS on it.
        ^$

6. ^\(64512) ==removes special meaning from the parentheses.
    If in AS Path: (6733 982) 43 239 852 4439
            The AS inside the AS path with parentheses is Confederation.

7. Match everything:    .*

No comments:

Post a Comment