Metacharacter | Meaning |
^
|
Start of line
|
$
|
End
of line
|
|
|
Logical OR applied
between the preceding and succeeding characters 1
|
_
|
Any delimiter: blank, comma, start of line, or end of line 2
|
.
|
Any
single character
|
?
|
Zero
or one instance of the preceding character
|
*
|
Zero or more instances
of the preceding character
|
+
|
One or more instances of
the preceding character
|
(string)
|
Parentheses
combine enclosed string characters as a single entity when used with ?, *, or
+
|
[string]
|
Creates
a wildcard for which any of the single characters in the string can be used
to match that position in the AS_PATH
|
1. If preceded by a value in parentheses, the logic applies to the preceding string listed inside the parenth
eses, and not just to the preceding character.
2. This character is an underscore.
Sample | Regex What Type of AS_PATH It Would Match |
^123$ | An AS_PATH with only one AS, ASN 123. |
^123 | An AS_PATH whose first ASN begins with or is 123; includes 123, 1232, 12354, and so on. |
^123. | An AS_PATH whose first ASN is one of two things: a fourdigit number that begins with 123, or a number that begins with ASN 123 and is followed by a delimiter before the next ASN. (It does not match an AS_PATH of only ASN 123, because the period does not match the end-of-line.) |
^123+ | An AS_PATH whose first ASN begins with 123, with 1233, or is 12333. For example, it includes ASNs 1231 and 12331 because it does not specify what happens after the +. |
^123+_ | An AS_PATH whose first ASN is one of three numbers: 123, 1233, or 12333. It does not match 1231 and 12331, for example, because it requires a delimiter after the last 3. |
^123* | An AS_PATH whose first ASN begins with 12, 123, or 1233, or is 12333. Any character can follow these values, because the regex does not specify anything about the next character. For example, 121 would match because the * can represent 0occurrences of “3”. 1231 would match with * representing 1 occurrence of 3. |
^123*_ | An AS_PATH whose first ASN begins with 12, 123, or 1233, or is 12333. It does not include matches for 121, 1231, and 12331, because the next character must be a delimiter. |
^123? | An AS_PATH whose first ASN begins with either 12 or 123. |
^123_45$ | An AS_PATH with two autonomous systems, beginning with 123 and ending with 45. |
^123_.*_45$ | An AS_PATH beginning with AS 123 and ending in AS 45, with at least one other AS in between. |
^123_.*45 | An AS_PATH beginning with AS 123, with zero or more intermediate ASNs and delimiters, and ending with any AS whose last two digits are 45 (including simply AS 45). |
(^123_45$)|(^123_.*_45$) | An AS_PATH beginning with 123 and ending with AS 45, with zero or more other ASNs between the two. |
^123_45$|^123_.*_45$ | (Note: This is the same as the previous example, but without the parentheses.) Represents a common error in attempting to match AS_PATHs that begin with ASN 123 and end with ASN 45. The problem is that the | is applied to the previous character ($) and next character (^), as opposed to everything before and after the |. |
^123(_[0..9]+)*_45 | Another way to match an AS_PATH beginning with 123 and ending with AS 45. |
^{123 | The AS_PATH begins with an AS_SET or AS_CONFED_SET, with the first three numerals of the first ASN being 123. |
[(]303.*[)] | Find the AS_CONFED_SEQ, and match if the first ASNbegins with 303 |