From 21d9ad8b119b81735946563f7edd4b5f1ba4cad7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 27 Aug 2014 11:19:41 +0200 Subject: QString:add (last)indexOf overload with QRegularExpressionMatch output This patch adds indexOf and lastIndexOf with QRegularExpressionMatch output overloads to QString. This allows to get the match corresponding to the index returned. [ChangeLog][QtCore][QString] Added support for retrieving the QRegularExpressionMatch to indexOf and lastIndexOf. Change-Id: Ia0ae2d3ff78864c7053ffa397874aca1d2b1c35c Reviewed-by: Marc Mutz --- src/corelib/doc/snippets/qstring/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib/doc') diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index bf45a31c29..f5c6b69695 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -394,6 +394,13 @@ void Widget::firstIndexOfFunction() QString str = "the minimum"; str.indexOf(QRegularExpression("m[aeiou]"), 0); // returns 4 //! [93] + + //! [97] + QString str = "the minimum"; + QRegularExpressionMatch match; + str.indexOf(QRegularExpression("m[aeiou]"), 0, &match); // returns 4 + // match.captured() == mi + //! [97] } void Widget::insertFunction() @@ -444,6 +451,13 @@ void Widget::lastIndexOfFunction() QString str = "the minimum"; str.lastIndexOf(QRegularExpression("m[aeiou]")); // returns 8 //! [94] + + //! [98] + QString str = "the minimum"; + QRegularExpressionMatch match; + str.lastIndexOf(QRegularExpression("m[aeiou]"), -1, &match); // returns 8 + // match.captured() == mu + //! [98] } void Widget::leftFunction() -- cgit v1.2.3