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 (const regExp &)=delete | |
Disallow default bitwise copy construction. 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 regExp &)=delete |
Disallow default bitwise assignment. 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... | |
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 |
||
) |
regExp | ( | const std::string & | pattern, |
const bool | ignoreCase = false |
||
) |
~regExp | ( | ) |
Destructor.
Definition at line 108 of file regExp.C.
References regExp::clear().
|
inlinestatic |
Is character a regular expression meta-character?
any character: '.'
quantifiers: '*', '+', '?'
grouping: '(', '|', ')'
range: '[', ']'
Don't bother checking for '{digit}' bounds
Definition at line 92 of file regExp.H.
Referenced by wordRe::meta().
|
inline |
|
inline |
Does a precompiled expression exist?
Definition at line 134 of file regExp.H.
Referenced by wordRe::compile(), wordRe::isPattern(), wordRe::match(), and wordRe::recompile().
|
inline |
Return the number of (groups)
Definition at line 140 of file regExp.H.
References regExp::clear(), regExp::find(), and regExp::match().
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 regExp::clear(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
Referenced by wordRe::compile().
void set | ( | const std::string & | pattern, |
const bool | ignoreCase = false |
||
) | const |
bool clear | ( | ) | const |
Release precompiled expression.
Returns true if precompiled expression existed before clear
Definition at line 169 of file regExp.C.
Referenced by wordRe::clear(), wordRe::compile(), regExp::ngroups(), wordRe::operator=(), regExp::set(), wordRe::uncompile(), and regExp::~regExp().
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::ngroups(), and 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(), regExp::match(), wordRe::match(), regExp::ngroups(), and STARCDsurfaceFormatCore::readInpCellTable().
bool match | ( | const std::string & | str, |
List< std::string > & | groups | ||
) | const |
Return true if it matches and sets the sub-groups matched.
The begin-of-line (^) and end-of-line ($) anchors are implicit
Definition at line 225 of file regExp.C.
References regExp::match().
|
inline |
Return true if the regex was found within string.
Definition at line 180 of file regExp.H.
References regExp::find(), and regExp::operator=().
|
delete |
Disallow default bitwise assignment.
Referenced by regExp::search().
void operator= | ( | const char * | pat | ) |
void operator= | ( | const std::string & | pat | ) |