summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/qstring/main.cpp
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2014-08-27 11:19:41 +0200
committerSamuel Gaist <samuel.gaist@edeltech.ch>2014-08-27 15:38:00 +0200
commit21d9ad8b119b81735946563f7edd4b5f1ba4cad7 (patch)
tree257f2324c684a0c3c886f8138f35d50c8fbbdeab /src/corelib/doc/snippets/qstring/main.cpp
parenta8a8a3bfbd4539e242360bc8a561390bbf9615f7 (diff)
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 <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/doc/snippets/qstring/main.cpp')
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp14
1 files changed, 14 insertions, 0 deletions
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()