
How to Use Regular Expressions
Regular Expression Terms
The terms in this section describe the components of regular expressions.
l
A regular expression (RE) is one or more non-empty
branches
, separated by pipe symbols (|). An
expression matches anything that matches one of the
branches
.
l A branch consists of one or more concatenated
pieces
. A branch matches a match for the first
piece
,
followed by a match for the second, and so on.
l A piece is an atom optionally followed by a single *, +, or ?, or by a
bound
.
o
An atom followed by an asterisk (*) matches a sequence of0 or more matches of the atom.
o
An atom followed by a plus sign (+) matches a sequence of1 or more matches of the atom.
o
An atom followed by a question mark (?) matches a sequence of0 or 1 matches of the atom.
l A bound consists of an open brace ({) followed by an unsigned decimal integer, between 0 and 255
inclusive. You can follow the first unsigned decimal integer with a comma, or a comma and a second
unsigned decimal integer. Close the
bound
with a close brace (}). If there are two integers, the value of the
first may not exceed the value of the second.
Learning About Atoms
An atom followed by a bound that contains one integer i and no comma matches a sequence of exactly i matches
of the atom. An atom followed by a bound that contains one integer i and a comma matches a sequence of i or
more matches of the atom. An atom followed by a bound containing two integers i and j matches a sequence of i
through j (inclusive) matches of the atom. An atom can consist of any of the following:
l A regular expression enclosed in parentheses, which matches a match for the regular expression.
l An empty set of parentheses, which matches the null string.
l A bracket expression.
l A period (.), which matches any single character.
l A carat (^), which matches the null string at the beginning of a line.
l A dollar sign ($), which matches the null string at the end of a line.
l A backslash (\) followed by one of the following characters: ^.[$()|*+?{\, which matches that character taken
as an ordinary character.
l A backslash (\) followed by any other character, which matches that character taken as an ordinary
character (as if the \ had not been present).
548
Copyright © 2013 Coyote Point Systems. A subsidiary of Fortinet, Inc.
Comentarios a estos manuales