Wrapper around POSIX extended 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...
Public Types | |
typedef SubStrings< std::string > | results_type |
Type for matches - similar to std::smatch. More... | |
using | meta = regExpCxx::meta |
Functor wrapper for testing meta-characters. More... | |
Public Member Functions | |
regExpPosix () noexcept | |
Default construct. More... | |
regExpPosix (const regExpPosix &)=delete | |
Copy construct - disallowed. More... | |
regExpPosix (regExpPosix &&rgx) noexcept | |
Move construct. More... | |
regExpPosix (const char *pattern, const bool ignoreCase=false) | |
Construct from character array, optionally ignore case. More... | |
regExpPosix (const std::string &pattern, const bool ignoreCase=false) | |
Construct from string, optionally ignore case. More... | |
~regExpPosix () | |
Destructor. More... | |
bool | empty () const noexcept |
Return true if a precompiled expression does not exist. More... | |
bool | exists () const noexcept |
Return true if a precompiled expression exists. 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 | clear () |
Clear expression. More... | |
void | swap (regExpPosix &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 regExpPosix &)=delete |
Copy assignment - disallowed. More... | |
void | operator= (regExpPosix &&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 |
Grammar (unused) - for compatibility with Foam::regExpCxx. More... | |
Wrapper around POSIX extended 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) matchingPerl
and sed
regular expressions.Definition at line 80 of file regExpPosix.H.
typedef SubStrings<std::string> results_type |
Type for matches - similar to std::smatch.
Definition at line 118 of file regExpPosix.H.
using meta = regExpCxx::meta |
Functor wrapper for testing meta-characters.
Definition at line 157 of file regExpPosix.H.
|
inlinenoexcept |
Default construct.
Definition at line 25 of file regExpPosixI.H.
|
delete |
Copy construct - disallowed.
|
inlinenoexcept |
Move construct.
Definition at line 32 of file regExpPosixI.H.
|
inlineexplicit |
Construct from character array, optionally ignore case.
Definition at line 43 of file regExpPosixI.H.
|
inlineexplicit |
Construct from string, optionally ignore case.
Definition at line 56 of file regExpPosixI.H.
|
inline |
Destructor.
Definition at line 70 of file regExpPosixI.H.
References clear().
|
inlinestaticnoexcept |
Test if character is a regex meta-character.
Definition at line 134 of file regExpPosix.H.
References Foam::constant::universal::c, and regExpCxx::is_meta().
Referenced by wordRe::compile().
|
inlinestatic |
Test if string contains any (unquoted) meta-characters.
Definition at line 143 of file regExpPosix.H.
References regExpCxx::is_meta().
|
inlinenoexcept |
Return true if a precompiled expression does not exist.
Definition at line 78 of file regExpPosixI.H.
|
inlinenoexcept |
Return true if a precompiled expression exists.
Definition at line 84 of file regExpPosixI.H.
|
inlinenoexcept |
True if pattern matching is negated.
Definition at line 90 of file regExpPosixI.H.
|
inlinenoexcept |
Change pattern negation, return previous value.
Definition at line 96 of file regExpPosixI.H.
|
inline |
The number of capture groups for a non-empty, non-negated expressions.
Definition at line 116 of file regExpPosixI.H.
bool clear | ( | ) |
Clear expression.
Definition at line 128 of file regExpPosix.C.
|
inline |
Swap contents.
Definition at line 160 of file regExpPosixI.H.
|
inline |
Compile pattern into a regular expression, optionally ignore case.
Definition at line 122 of file regExpPosixI.H.
|
inline |
Compile pattern into a regular expression, optionally ignore case.
Definition at line 134 of file regExpPosixI.H.
std::string::size_type find | ( | const std::string & | text | ) | const |
Find position within the text.
Definition at line 144 of file regExpPosix.C.
bool match | ( | const std::string & | text | ) | const |
True if the regex matches the entire text.
The begin-of-line (^) and end-of-line ($) anchors are implicit
Definition at line 187 of file regExpPosix.C.
Referenced by keyType::match(), and STARCDsurfaceFormatCore::readInpCellTable().
bool match | ( | const std::string & | text, |
results_type & | matches | ||
) | const |
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
|
inline |
Return true if the regex was found within the text.
Definition at line 145 of file regExpPosixI.H.
References Foam::ListOps::find().
|
inline |
Perform match on text.
Definition at line 173 of file regExpPosixI.H.
References Foam::stringOps::match().
|
delete |
Copy assignment - disallowed.
|
inline |
Move assignment.
Definition at line 179 of file regExpPosixI.H.
References clear().
|
inline |
Assign and compile pattern from a character array.
Matching is case sensitive.
Definition at line 190 of file regExpPosixI.H.
|
inline |
Assign and compile pattern from string.
Matching is case sensitive.
Definition at line 196 of file regExpPosixI.H.
|
static |
Grammar (unused) - for compatibility with Foam::regExpCxx.
Definition at line 126 of file regExpPosix.H.