Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is loosely oriented on PCRE regular expressions and provides a simple means of tuning the expressions. More...
Classes | |
struct | meta |
Functor wrapper for testing meta-characters. More... | |
Public Types | |
typedef std::smatch | results_type |
Type for matches. More... | |
Public Member Functions | |
regExpCxx () | |
Default construct. More... | |
regExpCxx (const regExpCxx &rgx) | |
Copy construct. More... | |
regExpCxx (regExpCxx &&rgx) noexcept | |
Move construct. More... | |
regExpCxx (const char *pattern, const bool ignoreCase=false) | |
Construct from character array, optionally ignore case. More... | |
regExpCxx (const std::string &pattern, const bool ignoreCase=false) | |
Construct from string, optionally ignore case. More... | |
~regExpCxx ()=default | |
Destructor. More... | |
bool | empty () const noexcept |
True if expression is empty. More... | |
bool | exists () const noexcept |
True if expression is non-empty. More... | |
bool | negated () const noexcept |
True if pattern matching is negated. More... | |
bool | negate (bool on) noexcept |
Change pattern negation, return previous value. More... | |
unsigned | ngroups () const |
The number of capture groups for a non-empty, non-negated expressions. More... | |
bool | nocase () const |
bool | clear () |
Clear expression. More... | |
void | swap (regExpCxx &rgx) |
Swap contents. More... | |
bool | set (const char *pattern, bool ignoreCase=false) |
Compile pattern into a regular expression, optionally ignore case. More... | |
bool | set (const std::string &pattern, bool ignoreCase=false) |
Compile pattern into a regular expression, optionally ignore case. More... | |
std::string::size_type | find (const std::string &text) const |
Find position within the text. More... | |
bool | match (const std::string &text) const |
True if the regex matches the entire text. More... | |
bool | match (const std::string &text, results_type &matches) const |
True if the regex matches the text, set the matches. More... | |
bool | search (const std::string &text) const |
Return true if the regex was found within the text. More... | |
bool | operator() (const std::string &text) const |
Perform match on text. More... | |
void | operator= (const regExpCxx &rgx) |
Copy assignment. More... | |
void | operator= (regExpCxx &&rgx) |
Move assignment. More... | |
void | operator= (const char *pattern) |
Assign and compile pattern from a character array. More... | |
void | operator= (const std::string &pattern) |
Assign and compile pattern from string. More... | |
Static Public Member Functions | |
static bool | is_meta (const char c) noexcept |
Test if character is a regex meta-character. More... | |
static bool | is_meta (const std::string &str, const char quote='\\') |
Test if string contains any (unquoted) meta-characters. More... | |
Static Public Attributes | |
static int | grammar |
The default grammar (extended | ECMAScript). More... | |
Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is loosely oriented on PCRE regular expressions and provides a simple means of tuning the expressions.
The prefixes are detected as (?...) at the beginning of the regular expression. Any unknown/unsupported prefixes are silently ignored.
'i'
indicates ignore-case'!'
(exclamation) indicates negated (inverted) matchingSince ECMAScript grammar may not work correctly on all installations, the current default is to use extended regular expressions.
The C++11 regular expressions may be broken on some compilers. For example, gcc 4.8 is known to fail. For these systems the POSIX implementation or alternative must be used.
Definition at line 78 of file regExpCxx.H.
typedef std::smatch results_type |
Type for matches.
Definition at line 123 of file regExpCxx.H.
|
inline |
Default construct.
Definition at line 75 of file regExpCxxI.H.
Copy construct.
Definition at line 82 of file regExpCxxI.H.
Move construct.
Definition at line 89 of file regExpCxxI.H.
|
inlineexplicit |
Construct from character array, optionally ignore case.
Definition at line 99 of file regExpCxxI.H.
|
inlineexplicit |
Construct from string, optionally ignore case.
Definition at line 112 of file regExpCxxI.H.
|
default |
Destructor.
|
inlinestaticnoexcept |
Test if character is a regex meta-character.
Definition at line 35 of file regExpCxxI.H.
References Foam::constant::universal::c.
Referenced by regExpPosix::is_meta(), and regExpCxx::meta::operator()().
|
inlinestatic |
Test if string contains any (unquoted) meta-characters.
Definition at line 48 of file regExpCxxI.H.
References Foam::constant::universal::c.
|
inlinenoexcept |
True if expression is empty.
Definition at line 126 of file regExpCxxI.H.
|
inlinenoexcept |
True if expression is non-empty.
Definition at line 132 of file regExpCxxI.H.
|
inlinenoexcept |
True if pattern matching is negated.
Definition at line 138 of file regExpCxxI.H.
|
inlinenoexcept |
Change pattern negation, return previous value.
Definition at line 144 of file regExpCxxI.H.
|
inline |
The number of capture groups for a non-empty, non-negated expressions.
Definition at line 164 of file regExpCxxI.H.
|
inline |
Definition at line 171 of file regExpCxxI.H.
|
inline |
Clear expression.
Definition at line 177 of file regExpCxxI.H.
|
inline |
Swap contents.
Definition at line 191 of file regExpCxxI.H.
|
inline |
Compile pattern into a regular expression, optionally ignore case.
Definition at line 202 of file regExpCxxI.H.
|
inline |
Compile pattern into a regular expression, optionally ignore case.
Definition at line 214 of file regExpCxxI.H.
|
inline |
Find position within the text.
Definition at line 226 of file regExpCxxI.H.
|
inline |
True if the regex matches the entire text.
The begin-of-line (^) and end-of-line ($) anchors are implicit
Definition at line 282 of file regExpCxxI.H.
|
inline |
True if the regex matches the text, set the matches.
The first group starts at index 1 (0 is the entire match). The begin-of-line (^) and end-of-line ($) anchors are implicit
Definition at line 297 of file regExpCxxI.H.
References Foam::stringOps::match().
|
inline |
Return true if the regex was found within the text.
Definition at line 268 of file regExpCxxI.H.
|
inline |
Perform match on text.
Definition at line 315 of file regExpCxxI.H.
References Foam::stringOps::match().
|
inline |
Copy assignment.
Definition at line 321 of file regExpCxxI.H.
|
inline |
Move assignment.
Definition at line 332 of file regExpCxxI.H.
References clear().
|
inline |
Assign and compile pattern from a character array.
Matching is case sensitive.
Definition at line 343 of file regExpCxxI.H.
|
inline |
Assign and compile pattern from string.
Matching is case sensitive.
Definition at line 349 of file regExpCxxI.H.
|
static |
The default grammar (extended | ECMAScript).
Definition at line 131 of file regExpCxx.H.
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.