CopperSpice API
1.9.2
|
Provides the results of matching a QRegularExpression for a given string. More...
Public Methods | |
QRegularExpressionMatch () = default | |
QRegularExpressionMatch (const QRegularExpressionMatch &other) = default | |
QRegularExpressionMatch (QRegularExpressionMatch &&other) = default | |
S | captured (const S &name) const |
S | captured (int index=0) const |
S | captured (QStringView< S > name) const |
S::const_iterator | capturedEnd (const S &name) const |
S::const_iterator | capturedEnd (int index=0) const |
S::const_iterator | capturedEnd (QStringView< S > name) const |
int | capturedLength (const S &name) const |
int | capturedLength (int index=0) const |
int | capturedLength (QStringView< S > name) const |
S::const_iterator | capturedStart (const S &name) const |
S::const_iterator | capturedStart (int index=0) const |
S::const_iterator | capturedStart (QStringView< S > name) const |
QList< S > | capturedTexts () const |
QStringView< S > | capturedView (const S &name) const |
QStringView< S > | capturedView (int index=0) const |
QStringView< S > | capturedView (QStringView< S > name) const |
int | captureIndexForName (const S &name) const |
int | captureIndexForName (QStringView< S > name) const |
bool | hasMatch () const |
bool | hasPartialMatch () const |
bool | isValid () const |
int | lastCapturedIndex () const |
QMatchOptionFlags | matchOptions () const |
QMatchType | matchType () const |
QRegularExpressionMatch & | operator= (const QRegularExpressionMatch &other) = default |
QRegularExpressionMatch & | operator= (QRegularExpressionMatch &&other) = default |
void | swap (QRegularExpressionMatch &other) |
A QRegularExpressionMatch can be obtained by calling QRegularExpression::match() or as a single result of a QRegularExpression::globalMatch(). The success or failure of a match attempt can be inspected by calling hasMatch() or hasPartialMatch().
QRegularExpressionMatch returns the substrings captured by the capturing groups in the pattern string. The implicit capturing group with index 0 captures the result of the whole match. The captured() method returns each substring captured, either by the capturing group's index or by its name.
For each captured substring you can query the starting and ending offsets in the pattern by calling capturedStart() and capturedEnd(), respectively. The length of each captured substring is available using the capturedLength() method.
The method capturedTexts() will return a sorted QList of all captured substrings, including the substring matched by the entire pattern.
|
default |
Constructs a valid empty QRegularExpressionMatch object. An empty QRegularExpressionMatch has no captures and hasMatch() will return false.
|
default |
Copy constructs a new QRegularExpressionMatch from other.
|
default |
Move constructs a new of QRegularExpressionMatch from other.
S QRegularExpressionMatch< S >::captured | ( | const S & | name | ) | const |
Returns the substring captured by the capturing group name. If the named capturing group did not capture a string or if there is no capturing group matching the specified name, an empty string is returned.
|
inline |
Returns the substring captured by the index capturing group.
An index value of 0 will return the entire match. If you want to return the contents of the first capture group pass a value of 1. Pass a value of 2 to return the contents of the second capture group, and so on.
If the index capturing group did not capture a string or if there is no such capturing group then an empty string is returned.
S QRegularExpressionMatch< S >::captured | ( | QStringView< S > | name | ) | const |
Returns the substring captured by the capturing string view group name. If the named capturing group did not capture a string or if there is no capturing group matching the specified name, returns an empty string.
S::const_iterator QRegularExpressionMatch< S >::capturedEnd | ( | const S & | name | ) | const |
Returns the position in the string immediately after the last code point captured by the capturing group name. If the capturing group did not capture a string or does not exist, returns end().
S::const_iterator QRegularExpressionMatch< S >::capturedEnd | ( | int | index = 0 | ) | const |
Returns the position in the string immediately after the last code point captured by the index capturing group. If the capturing group did not capture a string or does not exist, returns end().
S::const_iterator QRegularExpressionMatch< S >::capturedEnd | ( | QStringView< S > | name | ) | const |
Returns the position in the string immediately after the last code point captured by the capturing group name. If the capturing group did not capture a string or does not exist, returns end().
int QRegularExpressionMatch< S >::capturedLength | ( | const S & | name | ) | const |
Returns the length of the substring captured by the capturing group name. Returns 0 if the named capturing group did not capture a string or if there is no capturing group matching the specified name,
int QRegularExpressionMatch< S >::capturedLength | ( | int | index = 0 | ) | const |
Returns the length of the substring captured by the index capturing group. Returns 0 if the index capturing group did not capture a string or does not exist.
int QRegularExpressionMatch< S >::capturedLength | ( | QStringView< S > | name | ) | const |
Returns the length of the substring captured by the capturing group string view name. Returns 0 if the named capturing group did not capture a string or if there is no capturing group matching the specified name,
S::const_iterator QRegularExpressionMatch< S >::capturedStart | ( | const S & | name | ) | const |
Returns the position in the string corresponding to the first code point captured by the capturing group name. If the capturing group did not capture a string or does not exist, returns end().
S::const_iterator QRegularExpressionMatch< S >::capturedStart | ( | int | index = 0 | ) | const |
Returns the position in the string corresponding to the first code point captured by the index capturing group. If the capturing group did not capture a string or does not exist, returns end().
S::const_iterator QRegularExpressionMatch< S >::capturedStart | ( | QStringView< S > | name | ) | const |
Returns the position in the string corresponding to the first code point captured by the capturing group name. If the capturing group did not capture a string or does not exist, returns end().
QList< S > QRegularExpressionMatch< S >::capturedTexts | ( | ) | const |
Returns a list of all strings captured by capturing groups, in the order the groups appear in the pattern.
QStringView< S > QRegularExpressionMatch< S >::capturedView | ( | const S & | name | ) | const |
Returns the substring captured by the capturing group named name. If the named capturing group did not capture a string or if there is no capturing group matching the specified name, returns an empty string view.
|
inline |
Returns the substring captured by the index capturing group. If the index capturing group did not capture a string or if there is no such capturing group, returns an empty string view.
QStringView< S > QRegularExpressionMatch< S >::capturedView | ( | QStringView< S > | name | ) | const |
Returns the substring captured by the capturing group string view name. If the named capturing group did not capture a string or if there is no capturing group matching the specified name, returns an empty string view.
int QRegularExpressionMatch< S >::captureIndexForName | ( | const S & | name | ) | const |
Returns the index for the capture group with the specified name.
int QRegularExpressionMatch< S >::captureIndexForName | ( | QStringView< S > | name | ) | const |
Returns the index for the capture group with the specified string view name.
|
inline |
Returns true if the regular expression matched the string, or false otherwise.
|
inline |
Returns true if the regular expression partially matched the string or false otherwise. If a full match occurred this method will return false while the hasMatch() method will return true.
A partial match will only be attempted if the partial match flag is set in the QRegularExpression.
|
inline |
Returns true if the match object was found as a result of calling QRegularExpression::match(), returns false if the QRegularExpression was invalid.
|
inline |
Returns the index of the last capturing group that captured something, including the implicit capturing group 0. This can be used to extract all the substrings captured. If the regular expression did not match, this function returns -1.
Some of the capturing groups with an index less than lastCapturedIndex() may not have matched and therefore captured nothing.
QMatchOptionFlags QRegularExpressionMatch< S >::matchOptions | ( | ) | const |
Returns the match options passed to QRegularExpression::match() or QRegularExpression::globalMatch() to obtain this QRegularExpressionMatch object.
QMatchType QRegularExpressionMatch< S >::matchType | ( | ) | const |
Returns the match type passed to QRegularExpression::match() or QRegularExpression::globalMatch() to obtain this QRegularExpressionMatch object.
|
default |
Copy assigns from other and returns a reference to this object.
|
default |
Move assigns from other and returns a reference to this object.
|
inline |
Swaps the match result other with this match result. This operation is very fast and never fails.