[][src]Struct qt_core::QRegularExpressionMatch

#[repr(C)]pub struct QRegularExpressionMatch { /* fields omitted */ }

The QRegularExpressionMatch class provides the results of a matching a QRegularExpression against a string.

C++ class: QRegularExpressionMatch.

C++ documentation:

The QRegularExpressionMatch class provides the results of a matching a QRegularExpression against a string.

A QRegularExpressionMatch object can be obtained by calling the QRegularExpression::match() function, or as a single result of a global match from a QRegularExpressionMatchIterator.

The success or the failure of a match attempt can be inspected by calling the hasMatch() function. QRegularExpressionMatch also reports a successful partial match through the hasPartialMatch() function.

In addition, 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() function returns each substring captured, either by the capturing group's index or by its name:

QRegularExpression re("(\d\d) (?<name>\w+)"); QRegularExpressionMatch match = re.match("23 Jordan"); if (match.hasMatch()) { QString number = match.captured(1); // first == "23" QString name = match.captured("name"); // name == "Jordan" }

For each captured substring it is possible to query its starting and ending offsets in the subject string by calling the capturedStart() and the capturedEnd() function, respectively. The length of each captured substring is available using the capturedLength() function.

The convenience function capturedTexts() will return all the captured substrings at once (including the substring matched by the entire pattern) in the order they have been captured by captring groups; that is, captured(i) == capturedTexts().at(i).

You can retrieve the QRegularExpression object the subject string was matched against by calling the regularExpression() function; the match type and the match options are available as well by calling the matchType() and the matchOptions() respectively.

Please refer to the QRegularExpression documentation for more information about the Qt regular expression classes.

Methods

impl QRegularExpressionMatch[src]

pub unsafe fn captured_int(&self, nth: c_int) -> CppBox<QString>[src]

Returns the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QString.

Calls C++ function: QString QRegularExpressionMatch::captured(int nth = …) const.

C++ documentation:

Returns the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QString.

See also capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().

pub unsafe fn captured_q_string(
    &self,
    name: impl CastInto<Ref<QString>>
) -> CppBox<QString>
[src]

Returns the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QString.

Calls C++ function: QString QRegularExpressionMatch::captured(const QString& name) const.

C++ documentation:

Returns the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QString.

See also capturedRef(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().

pub unsafe fn captured(&self) -> CppBox<QString>[src]

Returns the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QString.

Calls C++ function: QString QRegularExpressionMatch::captured() const.

C++ documentation:

Returns the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QString.

See also capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().

pub unsafe fn captured_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> CppBox<QString>
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the substring captured by the capturing group named name.

Calls C++ function: QString QRegularExpressionMatch::captured(QStringView name) const.

C++ documentation:

Returns the substring captured by the capturing group named name.

If the named capturing group name did not capture a string, or if there is no capturing group named name, returns a null QString.

This function was introduced in Qt 5.10.

See also capturedRef(), capturedView(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().

pub unsafe fn captured_end_int(&self, nth: c_int) -> c_int[src]

Returns the offset inside the subject string immediately after the ending position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedEnd(int nth = …) const.

C++ documentation:

Returns the offset inside the subject string immediately after the ending position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

See also capturedStart(), capturedLength(), and captured().

pub unsafe fn captured_end_q_string(
    &self,
    name: impl CastInto<Ref<QString>>
) -> c_int
[src]

Returns the offset inside the subject string immediately after the ending position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedEnd(const QString& name) const.

C++ documentation:

Returns the offset inside the subject string immediately after the ending position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

See also capturedStart(), capturedLength(), and captured().

pub unsafe fn captured_end(&self) -> c_int[src]

Returns the offset inside the subject string immediately after the ending position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedEnd() const.

C++ documentation:

Returns the offset inside the subject string immediately after the ending position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

See also capturedStart(), capturedLength(), and captured().

pub unsafe fn captured_end_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> c_int
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the offset inside the subject string immediately after the ending position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedEnd(QStringView name) const.

C++ documentation:

Returns the offset inside the subject string immediately after the ending position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

This function was introduced in Qt 5.10.

See also capturedStart(), capturedLength(), and captured().

pub unsafe fn captured_length_int(&self, nth: c_int) -> c_int[src]

Returns the length of the substring captured by the nth capturing group.

Calls C++ function: int QRegularExpressionMatch::capturedLength(int nth = …) const.

C++ documentation:

Returns the length of the substring captured by the nth capturing group.

Note: This function returns 0 if the nth capturing group did not capture a string or doesn't exist.

See also capturedStart(), capturedEnd(), and captured().

pub unsafe fn captured_length_q_string(
    &self,
    name: impl CastInto<Ref<QString>>
) -> c_int
[src]

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name.

Calls C++ function: int QRegularExpressionMatch::capturedLength(const QString& name) const.

C++ documentation:

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name.

Note: This function returns 0 if the capturing group named name did not capture a string or doesn't exist.

See also capturedStart(), capturedEnd(), and captured().

pub unsafe fn captured_length(&self) -> c_int[src]

Returns the length of the substring captured by the nth capturing group.

Calls C++ function: int QRegularExpressionMatch::capturedLength() const.

C++ documentation:

Returns the length of the substring captured by the nth capturing group.

Note: This function returns 0 if the nth capturing group did not capture a string or doesn't exist.

See also capturedStart(), capturedEnd(), and captured().

pub unsafe fn captured_length_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> c_int
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the length of the substring captured by the capturing group named name.

Calls C++ function: int QRegularExpressionMatch::capturedLength(QStringView name) const.

C++ documentation:

Returns the length of the substring captured by the capturing group named name.

Note: This function returns 0 if the capturing group named name did not capture a string or doesn't exist.

This function was introduced in Qt 5.10.

See also capturedStart(), capturedEnd(), and captured().

pub unsafe fn captured_ref_int(&self, nth: c_int) -> CppBox<QStringRef>[src]

Returns a reference to the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QStringRef.

Calls C++ function: QStringRef QRegularExpressionMatch::capturedRef(int nth = …) const.

C++ documentation:

Returns a reference to the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QStringRef.

See also captured(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().

pub unsafe fn captured_ref_q_string(
    &self,
    name: impl CastInto<Ref<QString>>
) -> CppBox<QStringRef>
[src]

Returns a reference to the string captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QStringRef.

Calls C++ function: QStringRef QRegularExpressionMatch::capturedRef(const QString& name) const.

C++ documentation:

Returns a reference to the string captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QStringRef.

See also captured(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().

pub unsafe fn captured_ref(&self) -> CppBox<QStringRef>[src]

Returns a reference to the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QStringRef.

Calls C++ function: QStringRef QRegularExpressionMatch::capturedRef() const.

C++ documentation:

Returns a reference to the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QStringRef.

See also captured(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().

pub unsafe fn captured_ref_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> CppBox<QStringRef>
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a reference to the string captured by the capturing group named name.

Calls C++ function: QStringRef QRegularExpressionMatch::capturedRef(QStringView name) const.

C++ documentation:

Returns a reference to the string captured by the capturing group named name.

If the named capturing group name did not capture a string, or if there is no capturing group named name, returns a null QStringRef.

This function was introduced in Qt 5.10.

See also captured(), capturedView(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().

pub unsafe fn captured_start_int(&self, nth: c_int) -> c_int[src]

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedStart(int nth = …) const.

C++ documentation:

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

See also capturedEnd(), capturedLength(), and captured().

pub unsafe fn captured_start_q_string(
    &self,
    name: impl CastInto<Ref<QString>>
) -> c_int
[src]

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedStart(const QString& name) const.

C++ documentation:

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

See also capturedEnd(), capturedLength(), and captured().

pub unsafe fn captured_start(&self) -> c_int[src]

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedStart() const.

C++ documentation:

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.

See also capturedEnd(), capturedLength(), and captured().

pub unsafe fn captured_start_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> c_int
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

Calls C++ function: int QRegularExpressionMatch::capturedStart(QStringView name) const.

C++ documentation:

Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.

This function was introduced in Qt 5.10.

See also capturedEnd(), capturedLength(), and captured().

pub unsafe fn captured_texts(&self) -> CppBox<QStringList>[src]

Returns a list of all strings captured by capturing groups, in the order the groups themselves appear in the pattern string.

Calls C++ function: QStringList QRegularExpressionMatch::capturedTexts() const.

C++ documentation:

Returns a list of all strings captured by capturing groups, in the order the groups themselves appear in the pattern string.

pub unsafe fn captured_view_int(&self, nth: c_int) -> CppBox<QStringView>[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a view of the substring captured by the nth capturing group.

Calls C++ function: QStringView QRegularExpressionMatch::capturedView(int nth = …) const.

C++ documentation:

Returns a view of the substring captured by the nth capturing group.

If the nth capturing group did not capture a string, or if there is no such capturing group, returns a null QStringView.

This function was introduced in Qt 5.10.

See also captured(), capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QStringView::isNull().

pub unsafe fn captured_view_q_string_view(
    &self,
    name: impl CastInto<Ref<QStringView>>
) -> CppBox<QStringView>
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a view of the string captured by the capturing group named name.

Calls C++ function: QStringView QRegularExpressionMatch::capturedView(QStringView name) const.

C++ documentation:

Returns a view of the string captured by the capturing group named name.

If the named capturing group name did not capture a string, or if there is no capturing group named name, returns a null QStringView.

This function was introduced in Qt 5.10.

See also captured(), capturedRef(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().

pub unsafe fn captured_view(&self) -> CppBox<QStringView>[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a view of the substring captured by the nth capturing group.

Calls C++ function: QStringView QRegularExpressionMatch::capturedView() const.

C++ documentation:

Returns a view of the substring captured by the nth capturing group.

If the nth capturing group did not capture a string, or if there is no such capturing group, returns a null QStringView.

This function was introduced in Qt 5.10.

See also captured(), capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QStringView::isNull().

pub unsafe fn copy_from(
    &self,
    match_: impl CastInto<Ref<QRegularExpressionMatch>>
) -> Ref<QRegularExpressionMatch>
[src]

Assigns the match result match to this object, and returns a reference to the copy.

Calls C++ function: QRegularExpressionMatch& QRegularExpressionMatch::operator=(const QRegularExpressionMatch& match).

C++ documentation:

Assigns the match result match to this object, and returns a reference to the copy.

pub unsafe fn has_match(&self) -> bool[src]

Returns true if the regular expression matched against the subject string, or false otherwise.

Calls C++ function: bool QRegularExpressionMatch::hasMatch() const.

C++ documentation:

Returns true if the regular expression matched against the subject string, or false otherwise.

See also QRegularExpression::match() and hasPartialMatch().

pub unsafe fn has_partial_match(&self) -> bool[src]

Returns true if the regular expression partially matched against the subject string, or false otherwise.

Calls C++ function: bool QRegularExpressionMatch::hasPartialMatch() const.

C++ documentation:

Returns true if the regular expression partially matched against the subject string, or false otherwise.

Note: Only a match that explicitly used the one of the partial match types can yield a partial match. Still, if such a match succeeds totally, this function will return false, while hasMatch() will return true.

See also QRegularExpression::match(), QRegularExpression::MatchType, and hasMatch().

pub unsafe fn is_valid(&self) -> bool[src]

Returns true if the match object was obtained as a result from the QRegularExpression::match() function invoked on a valid QRegularExpression object; returns false if the QRegularExpression was invalid.

Calls C++ function: bool QRegularExpressionMatch::isValid() const.

C++ documentation:

Returns true if the match object was obtained as a result from the QRegularExpression::match() function invoked on a valid QRegularExpression object; returns false if the QRegularExpression was invalid.

See also QRegularExpression::match() and QRegularExpression::isValid().

pub unsafe fn last_captured_index(&self) -> c_int[src]

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 that were captured:

Calls C++ function: int QRegularExpressionMatch::lastCapturedIndex() const.

C++ documentation:

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 that were captured:


  QRegularExpressionMatch match = re.match(string);
  for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
      QString captured = match.captured(i);
      // ...
  }

Note that some of the capturing groups with an index less than lastCapturedIndex() could have not matched, and therefore captured nothing.

If the regular expression did not match, this function returns -1.

See also captured(), capturedStart(), capturedEnd(), and capturedLength().

pub unsafe fn match_options(&self) -> QFlags<MatchOption>[src]

Returns the match options that were used to get this QRegularExpressionMatch object, that is, the match options that were passed to QRegularExpression::match() or QRegularExpression::globalMatch().

Calls C++ function: QFlags<QRegularExpression::MatchOption> QRegularExpressionMatch::matchOptions() const.

C++ documentation:

Returns the match options that were used to get this QRegularExpressionMatch object, that is, the match options that were passed to QRegularExpression::match() or QRegularExpression::globalMatch().

See also QRegularExpression::match(), regularExpression(), and matchType().

pub unsafe fn match_type(&self) -> MatchType[src]

Returns the match type that was used to get this QRegularExpressionMatch object, that is, the match type that was passed to QRegularExpression::match() or QRegularExpression::globalMatch().

Calls C++ function: QRegularExpression::MatchType QRegularExpressionMatch::matchType() const.

C++ documentation:

Returns the match type that was used to get this QRegularExpressionMatch object, that is, the match type that was passed to QRegularExpression::match() or QRegularExpression::globalMatch().

See also QRegularExpression::match(), regularExpression(), and matchOptions().

pub unsafe fn new() -> CppBox<QRegularExpressionMatch>[src]

Constructs a valid, empty QRegularExpressionMatch object. The regular expression is set to a default-constructed one; the match type to QRegularExpression::NoMatch and the match options to QRegularExpression::NoMatchOption.

Calls C++ function: [constructor] void QRegularExpressionMatch::QRegularExpressionMatch().

C++ documentation:

Constructs a valid, empty QRegularExpressionMatch object. The regular expression is set to a default-constructed one; the match type to QRegularExpression::NoMatch and the match options to QRegularExpression::NoMatchOption.

The object will report no match through the hasMatch() and the hasPartialMatch() member functions.

This function was introduced in Qt 5.1.

pub unsafe fn new_copy(
    match_: impl CastInto<Ref<QRegularExpressionMatch>>
) -> CppBox<QRegularExpressionMatch>
[src]

Constructs a match result by copying the result of the given match.

Calls C++ function: [constructor] void QRegularExpressionMatch::QRegularExpressionMatch(const QRegularExpressionMatch& match).

C++ documentation:

Constructs a match result by copying the result of the given match.

See also operator=().

pub unsafe fn regular_expression(&self) -> CppBox<QRegularExpression>[src]

Returns the QRegularExpression object whose match() function returned this object.

Calls C++ function: QRegularExpression QRegularExpressionMatch::regularExpression() const.

C++ documentation:

Returns the QRegularExpression object whose match() function returned this object.

See also QRegularExpression::match(), matchType(), and matchOptions().

pub unsafe fn swap(&self, other: impl CastInto<Ref<QRegularExpressionMatch>>)[src]

Swaps the match result other with this match result. This operation is very fast and never fails.

Calls C++ function: void QRegularExpressionMatch::swap(QRegularExpressionMatch& other).

C++ documentation:

Swaps the match result other with this match result. This operation is very fast and never fails.

Trait Implementations

impl CppDeletable for QRegularExpressionMatch[src]

unsafe fn delete(&self)[src]

Destroys the match result.

Calls C++ function: [destructor] void QRegularExpressionMatch::~QRegularExpressionMatch().

C++ documentation:

Destroys the match result.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.