Wrapper around POSIX extended regular expressions. More...
Public Member Functions | |
regExp () | |
Construct null. More... | |
regExp (const char *, const bool ignoreCase=false) | |
Construct from character array, optionally ignoring case. More... | |
regExp (const std::string &, const bool ignoreCase=false) | |
Construct from std::string (or string), optionally ignoring case. More... | |
~regExp () | |
Destructor. More... | |
bool | empty () const |
Return true if a precompiled expression does not exist. More... | |
bool | exists () const |
Does a precompiled expression exist? More... | |
int | ngroups () const |
Return the number of (groups) More... | |
void | set (const char *, const bool ignoreCase=false) const |
Compile pattern into a regular expression,. More... | |
void | set (const std::string &, const bool ignoreCase=false) const |
Compile pattern into a regular expression,. More... | |
bool | clear () const |
Release precompiled expression. More... | |
std::string::size_type | find (const std::string &str) const |
Find position within string. More... | |
bool | match (const std::string &) const |
Return true if it matches the entire string. More... | |
bool | match (const std::string &, List< std::string > &groups) const |
Return true if it matches and sets the sub-groups matched. More... | |
bool | match (const std::string &, List< string > &groups) const |
Return true if it matches and sets the sub-groups matched. More... | |
bool | search (const std::string &str) const |
Return true if the regex was found within string. More... | |
void | operator= (const char *) |
Assign and compile pattern from a character array. More... | |
void | operator= (const std::string &) |
Assign and compile pattern from string. More... | |
Static Public Member Functions | |
static bool | meta (char c) |
Is character a regular expression meta-character? More... | |
Private Member Functions | |
regExp (const regExp &) | |
Disallow default bitwise copy construct. More... | |
void | operator= (const regExp &) |
Disallow default bitwise assignment. More... | |
template<class StringType > | |
bool | matchGrouping (const std::string &, List< StringType > &groups) const |
Return true if it matches and sets the sub-groups matched. More... | |
Private Attributes | |
regex_t * | preg_ |
Precompiled regular expression. More... | |
Wrapper around POSIX extended regular expressions.
The PCRE '(?i)' extension is provided to compile the regular expression as being case-insensitive.
regExp | ( | const char * | pattern, |
const bool | ignoreCase = false |
||
) |
Construct from character array, optionally ignoring case.
Definition at line 90 of file regExp.C.
References regExp::set().
regExp | ( | const std::string & | pattern, |
const bool | ignoreCase = false |
||
) |
Construct from std::string (or string), optionally ignoring case.
Definition at line 98 of file regExp.C.
References regExp::set().
~regExp | ( | ) |
|
private |
Disallow default bitwise assignment.
|
private |
Return true if it matches and sets the sub-groups matched.
Templated to support both std::string and Foam::string
Definition at line 34 of file regExp.C.
References List::clear(), and List::setSize().
|
inlinestatic |
Is character a regular expression meta-character?
any character: '.'
quantifiers: '*', '+', '?'
grouping: '(', '|', ')'
range: '[', ']'
Don't bother checking for '{digit}' bounds
Definition at line 98 of file regExp.H.
Referenced by wordRe::meta().
|
inline |
Return true if a precompiled expression does not exist.
Definition at line 131 of file regExp.H.
References regExp::preg_.
|
inline |
Does a precompiled expression exist?
Definition at line 137 of file regExp.H.
References regExp::preg_.
|
inline |
void set | ( | const char * | pattern, |
const bool | ignoreCase = false |
||
) | const |
Compile pattern into a regular expression,.
optionally ignoring case
Definition at line 116 of file regExp.C.
References clear(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
Referenced by regExp::regExp().
void set | ( | const std::string & | pattern, |
const bool | ignoreCase = false |
||
) | const |
bool clear | ( | ) | const |
std::string::size_type find | ( | const std::string & | str | ) | const |
Find position within string.
Returns the index where it begins or string::npos if not found
Definition at line 184 of file regExp.C.
Referenced by regExp::search().
bool match | ( | const std::string & | str | ) | const |
Return true if it matches the entire string.
The begin-of-line (^) and end-of-line ($) anchors are implicit
Definition at line 201 of file regExp.C.
Referenced by keyType::match(), and STARCDsurfaceFormatCore::readInpCellTable().
bool match | ( | const std::string & | str, |
List< std::string > & | groups | ||
) | const |
|
inline |
Return true if the regex was found within string.
Definition at line 183 of file regExp.H.
References regExp::find().
void operator= | ( | const char * | pat | ) |
void operator= | ( | const std::string & | pat | ) |
|
mutableprivate |
Precompiled regular expression.
Definition at line 66 of file regExp.H.
Referenced by regExp::empty(), regExp::exists(), and regExp::ngroups().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.