Table 11: Regular Expression Operators for the match Statement
MatchesOperator
One instance of any character except the space.. (period)
Zero or more instances of the immediately preceding term.* (asterisk)
One or more instances of the immediately preceding term.+ (plus sign)
Zero or one instance of the immediately preceding term.? (question mark)
One of the terms that appear on either side of the pipe operator.| (pipe)
Any string except the one specified by the expression, when the
exclamation point appears at the start of the expression. Use of the
exclamation point is Junos OS–specific.
! (exclamation point)
Start of a line, when the caret appears outside square brackets.
One instance of any character that does not follow it within square
brackets, when the caret is the first character inside square brackets.
^ (caret)
End of a line.$ (dollar sign)
One instance of one of the enclosed alphanumeric characters. To
indicate a range of characters, use a hyphen ( - ) to separate the
beginning and ending characters of the range. For example, [a-z0-9]
matches any letter or number.
[ ] (paired square
brackets)
One instance of the evaluated value of the enclosed term.
Parentheses are used to indicate the order of evaluation in the regular
expression.
( ) (paired parentheses)
Using Regular
Expressions
Filter messages that belong to the interactive-commands facility, directing those that
include the string configure to the terminal of the root user:
[edit system syslog]
user root {
interactive-commands any;
match “.*configure.*”;
}
Messages like the following appear on the root user’s terminal when a user issues a
configure command to enter configuration mode:
timestamp router-name mgd[PID]: UI_CMDLINE_READ_LINE: User 'user', command
'configure private'
Filter messages that belong to the daemon facility and have severity error or higher,
directing them to the file /var/log/process-errors. Omit messages generated by the SNMP
process (snmpd), instead directing them to the file /var/log/snmpd-errors:
[edit system syslog]
file process-errors {
daemon error;
23Copyright © 2010, Juniper Networks, Inc.
Chapter 1: Configuring System Log Messages