B-2
User Guide for Cisco Security MARS Local Controller
78-17020-01
Appendix B Regular Expression Reference
Backslash
The original operation of PCRE was on strings of one-byte characters. However, there is now also
support for UTF-8 character strings. To use this, you must build PCRE to include UTF-8 support, and
then call pcre_compile() with the PCRE_UTF8 option. How this affects pattern matching is mentioned
in several places below. There is also a summary of UTF-8 features in the section on UTF-8 support in
the main PCRE page.
A regular expression is a pattern that is matched against a subject string from left to right. Most
characters stand for themselves in a pattern, and match the corresponding characters in the subject. As
a trivial example, the pattern
The quick brown fox
matches a portion of a subject string that is identical to itself. The power of regular expressions comes
from the ability to include alternatives and repetitions in the pattern. These are encoded in the pattern by
the use of
metacharacters
, which do not stand for themselves but instead are interpreted in some special
way.
There are two different sets of metacharacters: those that are recognized anywhere in the pattern except
within square brackets, and those that are recognized in square brackets. Outside square brackets, the
metacharacters are as follows:
\ general escape character with several uses
^ assert start of string (or line, in multiline mode)
$ assert end of string (or line, in multiline mode)
. match any character except newline (by default)
[ start character class definition
| start of alternative branch
( start subpattern
) end subpattern
? extends the meaning of (
also 0 or 1 quantifier
also quantifier minimizer
* 0 or more quantifier
+ 1 or more quantifier
also "possessive quantifier"
{ start min/max quantifier
Part of a pattern that is in square brackets is called a "character class". In a character class the only
metacharacters are:
\ general escape character
^ negate the class, but only if the first character
- indicates character range
[ POSIX character class (only if followed by POSIX syntax)
] terminates the character class
The following sections describe the use of each of the metacharacters.
Backslash
The backslash character has several uses. Firstly, if it is followed by a non-alphanumeric character, it
takes away any special meaning that character may have. This use of backslash as an escape character
applies both inside and outside character classes.
For example, if you want to match a * character, you write \* in the pattern. This escaping action applies
whether or not the following character would otherwise be interpreted as a metacharacter, so it is always
safe to precede a non-alphanumeric with backslash to specify that it stands for itself. In particular, if you
want to match a backslash, you write \\.
Содержание CS-MARS-20-K9 - Security MARS 20
Страница 20: ...Contents xx User Guide for Cisco Security MARS Local Controller 78 17020 01 ...
Страница 356: ...17 16 User Guide for Cisco Security MARS Local Controller 78 17020 01 Chapter 17 Network Summary Summary Page ...
Страница 420: ...20 28 User Guide for Cisco Security MARS Local Controller 78 17020 01 Chapter 20 Queries and Reports Reports ...
Страница 580: ...Glossary GL 4 User Guide for Cisco Security MARS Local Controller 78 17020 01 ...