Basic regular expression matching.
More...
|
| RegularExpression () |
| Default constructor.
|
|
| RegularExpression (const std::string &pattern, bool case_sensitive=true) |
| Constructor with a preinitialized pattern. More...
|
|
| ~RegularExpression () |
| DTOR.
|
|
| RegularExpression (const RegularExpression &other) |
| Copy constructor. More...
|
|
RegularExpression & | operator= (const RegularExpression &other) |
| Copy assignment operator. More...
|
|
bool | setPattern (const std::string &pattern, bool case_sensitive=true) |
| Set the regular expression pattern. More...
|
|
std::string | getPattern () const |
| Get the current pattern (expression). More...
|
|
const std::string & | getError () const |
| Get any error description for the pattern. More...
|
|
bool | fullMatch (const std::string &text) const |
| Check if the whole string matches the pattern. More...
|
|
bool | fullMatch (const std::string &text, std::string &arg1, std::string &arg2=noArg(), std::string &arg3=noArg(), std::string &arg4=noArg(), std::string &arg5=noArg(), std::string &arg6=noArg(), std::string &arg7=noArg(), std::string &arg8=noArg(), std::string &arg9=noArg(), std::string &arg10=noArg(), std::string &arg11=noArg(), std::string &arg12=noArg(), std::string &arg13=noArg(), std::string &arg14=noArg(), std::string &arg15=noArg(), std::string &arg16=noArg()) const |
| Check if the whole string matches the pattern, extracting up to 16 capture groups. More...
|
|
bool | match (const std::string &text, AnchorType anchor, int &consumed) const |
| Matches a string. More...
|
|
|
static std::string & | noArg () |
| Empty argument.
|
|
|
std::unique_ptr< Implementation > | _impl |
|
◆ AnchorType
◆ RegularExpression() [1/2]
Constructor with a preinitialized pattern.
- Parameters
-
[in] | pattern | The regular expression pattern |
[in] | case_sensitive | Whether or not the match is case sensitive |
- Note
- On error, the instance is initialized to the default state/the pattern is not set
◆ RegularExpression() [2/2]
Copy constructor.
- Parameters
-
[in] | other | The object to copy. |
◆ fullMatch() [1/2]
bool fullMatch |
( |
const std::string & |
text | ) |
const |
Check if the whole string matches the pattern.
- Parameters
-
[in] | text | The string to match |
- Returns
true
if the string matches, false
otherwise
◆ fullMatch() [2/2]
bool fullMatch |
( |
const std::string & |
text, |
|
|
std::string & |
arg1, |
|
|
std::string & |
arg2 = noArg() , |
|
|
std::string & |
arg3 = noArg() , |
|
|
std::string & |
arg4 = noArg() , |
|
|
std::string & |
arg5 = noArg() , |
|
|
std::string & |
arg6 = noArg() , |
|
|
std::string & |
arg7 = noArg() , |
|
|
std::string & |
arg8 = noArg() , |
|
|
std::string & |
arg9 = noArg() , |
|
|
std::string & |
arg10 = noArg() , |
|
|
std::string & |
arg11 = noArg() , |
|
|
std::string & |
arg12 = noArg() , |
|
|
std::string & |
arg13 = noArg() , |
|
|
std::string & |
arg14 = noArg() , |
|
|
std::string & |
arg15 = noArg() , |
|
|
std::string & |
arg16 = noArg() |
|
) |
| const |
Check if the whole string matches the pattern, extracting up to 16 capture groups.
- Parameters
-
[in] | text | The string to match |
[out] | arg1 | Capture argument 1 |
[out] | arg2 | Capture argument 2 |
[out] | arg3 | Capture argument 3 |
[out] | arg4 | Capture argument 4 |
[out] | arg5 | Capture argument 5 |
[out] | arg6 | Capture argument 6 |
[out] | arg7 | Capture argument 7 |
[out] | arg8 | Capture argument 8 |
[out] | arg9 | Capture argument 9 |
[out] | arg10 | Capture argument 10 |
[out] | arg11 | Capture argument 11 |
[out] | arg12 | Capture argument 12 |
[out] | arg13 | Capture argument 13 |
[out] | arg14 | Capture argument 14 |
[out] | arg15 | Capture argument 15 |
[out] | arg16 | Capture argument 16 |
- Returns
- @ true if the string matches,
false
otherwise
◆ getError()
const std::string& getError |
( |
| ) |
const |
Get any error description for the pattern.
- Returns
- The current error. Might be empty if the pattern is valid.
◆ getPattern()
std::string getPattern |
( |
| ) |
const |
Get the current pattern (expression).
- Returns
- The current pattern.
◆ match()
bool match |
( |
const std::string & |
text, |
|
|
AnchorType |
anchor, |
|
|
int & |
consumed |
|
) |
| const |
Matches a string.
- Parameters
-
[in] | text | The string to match |
[in] | anchor | See AnchorType |
[out] | consumed | The length of the match |
- Returns
true
if the string matches, false
otherwise
◆ operator=()
Copy assignment operator.
- Parameters
-
[in] | other | The element to copy to. |
- Returns
- A reference of the local object.
◆ setPattern()
bool setPattern |
( |
const std::string & |
pattern, |
|
|
bool |
case_sensitive = true |
|
) |
| |
Set the regular expression pattern.
- Parameters
-
[in] | pattern | The regular expression string |
[in] | case_sensitive | Whether or not the match is case sensitive |
- Returns
false
if the pattern is invalid, see getError for details