This utility class wraps boost::regex library and interfaces ALib Strings with it.
The availability of the class is dependent on the compiler-symbol ALIB_FEAT_BOOST_REGEX which has to be true
, and in parallel either ALIB_CHARACTERS_WIDE is false
or ALIB_CHARACTERS_NATIVE_WCHAR equals true
.
Method Compile accepts the pattern string and compiles it to boost::regex. Subsequent invocations of Match will then use the compiled regular expression for testing a given string.
The syntax of the regular expressions is compatible to Perl Regular Expressions .
Definition at line 33 of file regexmatcher.inl.
Public Method Index: | |
RegexMatcher (const String &pattern=NULL_STRING) | |
ALIB_DLL | ~RegexMatcher () |
Destructor. | |
ALIB_DLL void | Compile (const String &pattern) |
ALIB_DLL bool | Match (const String &haystack) |
Protected Field Index: | |
void * | boostRegex = nullptr |
|
protected |
This is the internal regex matcher. Yes, a nasty reinterpret_cast
is performed in the compilation unit. This is for avoiding the inclusion of external headers with ALib headers at the expense of an otherwise unnecessary heap allocation.
Definition at line 39 of file regexmatcher.inl.
|
inline |
Constructs a RegexMatcher to work on a given string. Passes the optional parameters to method Compile.
pattern | The string pattern to match. Defaults to NULL_STRING to allow parameterless construction, with later invocation of Compile. |
Definition at line 50 of file regexmatcher.inl.
Resets this object to use the given pattern.
pattern | The string pattern to match. |
Tests if given haystack matches the actual pattern. If Compile was not invoked or an empty pattern string was given, true
is returned.
haystack | The string to test. |
true
if given haystack matches the actual pattern, false
otherwise.