pcrecpp (3) - Linux Manuals
pcrecpp: Perl-compatible regular expressions.
NAME
PCRE - Perl-compatible regular expressions.
SYNOPSIS OF C++ WRAPPER
DESCRIPTION
The C++ wrapper for PCRE was provided by Google Inc. Some additional functionality was added by Giuseppe Maxia. This brief man page was constructed from the notes in the pcrecpp.h file, which should be consulted for further details. Note that the C++ wrapper supports only the original 8-bit PCRE library. There is no 16-bit or 32-bit support at present.
MATCHING INTERFACE
The "FullMatch" operation checks that supplied text matches a supplied pattern exactly. If pointer arguments are supplied, it copies matched sub-strings that match sub-patterns into them.
You can pass in a "const char*" or a "string" for "text". The examples below
tend to use a const char*. You can, as in the different examples above, store
the RE object explicitly in a variable or use a temporary RE object. The
examples below use one mode or the other arbitrarily. Either could correctly be
used for any of these examples.
You must supply extra pointer arguments to extract matched subpieces.
The provided pointer arguments can be pointers to any scalar numeric
type, or one of:
The function returns true iff all of the following conditions are satisfied:
CAVEAT: An optional sub-pattern that does not exist in the matched
string is assigned the empty string. Therefore, the following will
return false (because the empty string is not a valid number):
The matching interface supports at most 16 arguments per call.
If you need more, consider using the more general interface
pcrecpp::RE::DoMatch. See pcrecpp.h for the signature for
DoMatch.
NOTE: Do not use no_arg, which is used internally to mark the end of a
list of optional arguments, as a placeholder for missing arguments, as this can
lead to segfaults.
You can use the "QuoteMeta" operation to insert backslashes before all
potentially meaningful characters in a string. The returned string, used as a
regular expression, will exactly match the original string.
Note that it's legal to escape a character even if it has no special meaning in
a regular expression -- so this function does that. (This also makes it
identical to the perl function of the same name; see "perldoc -f quotemeta".)
For example, "1.5-2.0?" becomes "1\.5\-2\.0\?".
You can use the "PartialMatch" operation when you want the pattern
to match any substring of the text.
By default, pattern and text are plain text, one byte per character. The UTF8
flag, passed to the constructor, causes both pattern and string to be treated
as UTF-8 text, still a byte stream but potentially multiple bytes per
character. In practice, the text is likelier to be UTF-8 than the pattern, but
the match returned may depend on the UTF8 flag, so always use it when matching
UTF8 text. For example, "." will match one byte normally but with UTF8 set may
match up to three bytes of a multi-byte character.
NOTE: The UTF8 flag is ignored if pcre was not configured with the
PCRE defines some modifiers to change the behavior of the regular expression
engine. The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle to
pass such modifiers to a RE class. Currently, the following modifiers are
supported:
QUOTING METACHARACTERS
PARTIAL MATCHES
UTF-8 AND THE MATCHING INTERFACE
PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE