Represents a regular expression.
This class provides a simple interface for regular expression construction. regexMatch() is used to match the regular expression against a string. POSIX extended regular expression syntax is used.
Currently, isSupported() will return true if either
- POSIX regular expression header <regex.h> is available, or
- C++11 header <regex> is available (e.g., new enough MSVC has this).
In other cases, isSupported() returns false and calling other constructors than the default constructor throws an exception.
- See Also
- regexMatch()
bool regexMatch |
( |
const char * |
str, |
|
|
const Regex & |
regex |
|
) |
| |
|
friend |
Matches a string with a regular expression.
- Parameters
-
[in] | str | String to match. |
[in] | regex | Regular expression to match. |
- Returns
- true if
regex
matches the whole str
.
Does not throw currently, but this is subject to change if/when better error handling is implemented (currently, it returns false if the matching fails, e.g., because of out-of-memory).
bool regexMatch |
( |
const std::string & |
str, |
|
|
const Regex & |
regex |
|
) |
| |
|
friend |
Matches a string with a regular expression.
- Parameters
-
[in] | str | String to match. |
[in] | regex | Regular expression to match. |
- Returns
- true if
regex
matches the whole str
.
Does not throw currently, but this is subject to change if/when better error handling is implemented (currently, it returns false if the matching fails, e.g., because of out-of-memory).