Appendix B Regular Expression Reference; Backslash - Cisco CS-MARS-20-K9 - Security MARS 20 User Manual

Security mars local controller
Table of Contents

Advertisement

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
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:
Part of a pattern that is in square brackets is called a "character class". In a character class the only
metacharacters are:
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 \\.
User Guide for Cisco Security MARS Local Controller
B-2
The quick brown fox
\
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
\
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
Appendix B
Regular Expression Reference
78-17020-01

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mars 20Mars 50Mars 100Mars 200

Table of Contents