Owner's Manual
480
Using UNIX Regular Expressions
When specifying community-ids, you can use UNIX-style regular expressions to specify the AS
number and the member identifier. A regular expression consists of two components, which you
specify in the following format:
term<operator>
-
term
—identifies the string to match.
-
operator—
specifies how the term must match. The following table lists the regular expression
operators supported for the community attribute. You place an operator immediately after
term with no intervening space, except for the pipe ( | ) and dash (-) operators, which you
place between two terms, and parentheses, with which you enclose terms. The second table
shows examples of how to define community-ids using community regular expressions. The
operator is optional.
Community regular expressions are identical to the UNIX regular expressions. Both
implement the extended (or modern) regular expressions as defined in POSIX 1003.2.
NOTE:
Community regular expressions evaluate the string specified in term on a character-by-character basis.
For example, if you specify 1234:5678 as term, the regular expressions see nine discrete characters,
including the colon (:), instead of two sets of numbers (1234 and 5678) separated by a colon.
Supported Regular Expressions
Operator Match...
{m, n} At least m and at most n repetitions of term. Both m and n must be positive integers, and m
must be smaller than n.
{m} Exactly m repetitions of term. m must be a positive integer.
{m,} m or more repetitions of term. m must be a positive integer.
* Zero or more repetitions of term. This is equivalent to {0,}.
+ One or more repetitions of term. This is equivalent to {1,}.
? Zero or one repetition of term. This is equivalent to {0,1}.
| One of the two terms on either side of the pipe.
- Between a starting and ending range, inclusive.
^ Character at the beginning of a community attribute regular expression. We recommend the
use of this operator for the clearest interpretation of your community attribute regular
expression. If you do not use this operator, the regular expression 123:456 could also
match a route tagged with 5123:456.
$ Character at the end of a community attribute regular expression. We recommend the use of
this operator for the clearest interpretation of your community attribute regular expression.
If you do not use this operator, the regular expression 123:456 could also match a route
tagged with 123:4563.