Basic regular expression matching.
More...
#include <regularexpression.h>
|
| | RegularExpression () |
| |
| | RegularExpression (const std::string &pattern, bool case_sensitive=true) |
| |
| | ~RegularExpression () |
| |
| | RegularExpression (const RegularExpression &other) |
| |
| RegularExpression & | operator= (const RegularExpression &other) |
| |
| bool | setPattern (const std::string &pattern, bool case_sensitive=true) |
| |
| std::string | getPattern () const |
| |
| const std::string & | getError () const |
| |
| bool | fullMatch (const std::string &text) const |
| |
| 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 |
| |
| bool | match (const std::string &text, AnchorType anchor, int &consumed) const |
| |
Basic regular expression matching.
◆ AnchorType
Anchor type.
| Enumerator |
|---|
| AT_Unanchored | No anchoring.
|
| AT_Start | Anchor at start only.
|
| AT_Both | Anchor at start and end.
|
◆ RegularExpression() [1/3]
| a_util::regex::RegularExpression::RegularExpression |
( |
| ) |
|
◆ RegularExpression() [2/3]
| a_util::regex::RegularExpression::RegularExpression |
( |
const std::string & | pattern, |
|
|
bool | case_sensitive = true ) |
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()
| a_util::regex::RegularExpression::~RegularExpression |
( |
| ) |
|
◆ RegularExpression() [3/3]
| a_util::regex::RegularExpression::RegularExpression |
( |
const RegularExpression & | other | ) |
|
Copy constructor
- Parameters
-
| [in] | other | The object to copy. |
◆ fullMatch() [1/2]
| bool a_util::regex::RegularExpression::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 a_util::regex::RegularExpression::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 & a_util::regex::RegularExpression::getError |
( |
| ) |
const |
Get any error description for the pattern.
- Returns
- The current error. Might be empty if the pattern is valid.
◆ getPattern()
| std::string a_util::regex::RegularExpression::getPattern |
( |
| ) |
const |
Get the current pattern (expression).
- Returns
- The current pattern.
◆ match()
| bool a_util::regex::RegularExpression::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 a_util::regex::RegularExpression::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
The documentation for this class was generated from the following file: