From f7293e3580e880b9a0badaf76bb26f2d2e0bb3b4 Mon Sep 17 00:00:00 2001 From: Martin Rodriguez Reboredo Date: Sat, 20 Apr 2024 20:39:50 -0300 Subject: [PATCH] Substitute QRegExp with QRegularExpression --- Engine/CLArgs.cpp | 5 +++-- Engine/FileSystemModel.cpp | 10 ++++++---- Engine/Markdown.cpp | 11 +++++------ Engine/Node.cpp | 1 - Engine/NodeDocumentation.cpp | 3 ++- Engine/OutputEffectInstance.cpp | 4 ++-- Engine/Project.cpp | 14 ++++++++----- Gui/FileTypeMainWindow_win.cpp | 20 ++++++++++--------- Gui/GuiFwd.h | 1 + Gui/NodeCreationDialog.cpp | 17 +++++----------- Gui/NodeGraph45.cpp | 11 +++++------ Gui/PreferencesPanel.cpp | 4 +++- Gui/RenderStatsDialog.cpp | 12 ++++++----- Gui/ScriptTextEdit.cpp | 35 +++++++++++++++++++-------------- Gui/ScriptTextEdit.h | 2 +- Gui/SequenceFileDialog.h | 1 - Gui/ViewerGL.cpp | 5 +++-- 17 files changed, 83 insertions(+), 73 deletions(-) diff --git a/Engine/CLArgs.cpp b/Engine/CLArgs.cpp index e91b46cee..108d64e89 100644 --- a/Engine/CLArgs.cpp +++ b/Engine/CLArgs.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "Global/GlobalDefines.h" #include "Global/GitVersion.h" @@ -1139,10 +1140,10 @@ CLArgsPrivate::parse() // A clean solution would be to separate the scriptName and the fileName with a comma. if ( it != args.end() && !it->startsWith( QChar::fromLatin1('-') ) ) { // Check that it's neither a python script, a natron project, nor a frame range. - QRegExp re( QString::fromUtf8("[0-9\\-,]*") ); // Matches frame ranges. + QRegularExpression re( QString::fromUtf8("[0-9\\-,]*") ); // Matches frame ranges. if (!it->endsWith(QString::fromUtf8(".py"), Qt::CaseInsensitive) && !it->endsWith(QString::fromUtf8(".ntp"), Qt::CaseInsensitive) && - !re.exactMatch(*it)) { + !re.match(*it).hasMatch()) { w.filename = *it; #ifdef __NATRON_UNIX__ w.filename = AppManager::qt_tildeExpansion(w.filename); diff --git a/Engine/FileSystemModel.cpp b/Engine/FileSystemModel.cpp index a877d3eb3..b9457d1e6 100644 --- a/Engine/FileSystemModel.cpp +++ b/Engine/FileSystemModel.cpp @@ -47,6 +47,7 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include +#include CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) @@ -193,7 +194,7 @@ struct FileSystemModelPrivate QStringList headers; QDir::Filters filters; QString encodedRegexps; - std::list regexps; + std::list regexps; mutable QMutex filtersMutex; mutable QMutex sequenceModeEnabledMutex; bool sequenceModeEnabled; @@ -1041,7 +1042,8 @@ FileSystemModel::setRegexpFilters(const QString& filters) ++i; } if ( regExp != QString( QLatin1Char('*') ) ) { - QRegExp rx(regExp, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(regExp)); + rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); if ( rx.isValid() ) { _imp->regexps.push_back(rx); } @@ -1082,8 +1084,8 @@ FileSystemModel::isAcceptedByRegexps(const QString & path) const return true; } - for (std::list::const_iterator it = _imp->regexps.begin(); it != _imp->regexps.end(); ++it) { - if ( it->exactMatch(path) ) { + for (std::list::const_iterator it = _imp->regexps.begin(); it != _imp->regexps.end(); ++it) { + if ( it->match(path).hasMatch() ) { return true; } } diff --git a/Engine/Markdown.cpp b/Engine/Markdown.cpp index 718decd6a..c9dd2bf29 100644 --- a/Engine/Markdown.cpp +++ b/Engine/Markdown.cpp @@ -30,7 +30,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include -#include +#include CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) @@ -79,7 +79,7 @@ QString Markdown::parseCustomLinksForHTML(const QString& markdown) { QString result = markdown; - QRegExp rx( QString::fromUtf8("(\\|html::[^|]*\\|)\\|rst::[^|]*\\|") ); + QRegularExpression rx( QString::fromUtf8("(\\|html::[^|]*\\|)\\|rst::[^|]*\\|") ); result.replace( rx, QString::fromUtf8("\\1") ); return result; @@ -105,10 +105,9 @@ Markdown::fixSettingsHTML(const QString &html) QStringList list = html.split( QString::fromUtf8("\n") ); Q_FOREACH(const QString &line, list) { if ( line.startsWith(QString::fromUtf8("

")) ) { - QRegExp rx( QString::fromUtf8("

(.*)

") ); - rx.indexIn(line); - QString header = rx.cap(1); - QString headerLink = header.toLower(); + QRegularExpression rx( QString::fromUtf8("

(.*)

") ); + QString header(rx.match(line).captured(1)); + QString headerLink(header.toLower()); headerLink.replace( QString::fromUtf8(" "), QString::fromUtf8("-") ); result.append(QString::fromUtf8("

%2

").arg(headerLink).arg(header)); } else { diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 8d6add034..346fda974 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include diff --git a/Engine/NodeDocumentation.cpp b/Engine/NodeDocumentation.cpp index 4d1ff2af6..216789e5b 100644 --- a/Engine/NodeDocumentation.cpp +++ b/Engine/NodeDocumentation.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "Engine/EffectInstance.h" #include "Engine/KnobTypes.h" @@ -409,7 +410,7 @@ Node::makeDocumentation(bool genHTML) const pluginDescription = NATRON_NAMESPACE::convertFromPlainText(pluginDescription, NATRON_NAMESPACE::WhiteSpaceNormal); // replace URLs with links - QRegExp re( QString::fromUtf8("((http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?)") ); + QRegularExpression re( QString::fromUtf8("((http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?)") ); pluginDescription.replace( re, QString::fromUtf8("\\1") ); } else { pluginDescription = convertFromPlainTextToMarkdown(pluginDescription, genHTML, false); diff --git a/Engine/OutputEffectInstance.cpp b/Engine/OutputEffectInstance.cpp index 0db16894f..dd26f2855 100644 --- a/Engine/OutputEffectInstance.cpp +++ b/Engine/OutputEffectInstance.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include // QtCore on Qt4, QtConcurrent on Qt5 #include // QtCore on Qt4, QtConcurrent on Qt5 @@ -268,7 +268,7 @@ OutputEffectInstance::renderFullSequence(bool isBlocking, std::size_t foundHash = pattern.find_first_of("#"); if (foundHash == std::string::npos) { // Look for printf style numbering - QRegExp exp(QString::fromUtf8("%[0-9]*d")); + QRegularExpression exp(QString::fromUtf8("%[0-9]*d")); QString qp(QString::fromUtf8(pattern.c_str())); if (!qp.contains(exp)) { QString message = tr("You are trying to render the frame range [%1 - %2] but you did not specify any hash ('#') character(s) or printf-like format ('%d') for the padding. This will result in the same image being overwritten multiple times.").arg(first).arg(last); diff --git a/Engine/Project.cpp b/Engine/Project.cpp index 942a90902..c28dfb707 100644 --- a/Engine/Project.cpp +++ b/Engine/Project.cpp @@ -55,6 +55,7 @@ #include #include #include // QtCore on Qt4, QtConcurrent on Qt5 +#include #include // OFX::XML::escape @@ -504,7 +505,7 @@ findBackups(const QString & filePath) ret.append(filePath); } // find files matching filePath.~[0-9]+~ - QRegExp rx(QString::fromUtf8("\\.~(\\d+)~$")); + QRegularExpression rx(QString::fromUtf8("\\.~(\\d+)~$")); QFileInfo fileInfo(filePath); QString fileName = fileInfo.fileName(); QDirIterator it(fileInfo.dir()); @@ -518,7 +519,9 @@ findBackups(const QString & filePath) // If the filename contains target string - put it in the hitlist QString fn = file.fileName(); - if (fn.startsWith(fileName) && rx.lastIndexIn(fn) == fileName.size()) { + QRegularExpressionMatch match(rx.match(fileName)); + qsizetype pos = match.capturedEnd(); + if (fn.startsWith(fileName) && pos == fileName.size()) { ret.append(file.filePath()); } } @@ -532,10 +535,11 @@ findBackups(const QString & filePath) static QString nextBackup(const QString & filePath) { - QRegExp rx(QString::fromUtf8("\\.~(\\d+)~$")); - int pos = rx.lastIndexIn(filePath); + QRegularExpression rx(QString::fromUtf8("\\.~(\\d+)~$")); + QRegularExpressionMatch match(rx.match(filePath)); + int pos = match.capturedEnd(); if (pos >= 0) { - int i = rx.cap(1).toInt(); + int i = match.captured(1).toInt(); return filePath.left(pos) + QString::fromUtf8(".~%1~").arg(i+1); } else { return filePath + QString::fromUtf8(".~1~"); diff --git a/Gui/FileTypeMainWindow_win.cpp b/Gui/FileTypeMainWindow_win.cpp index 5cf275db4..a3c92abd3 100644 --- a/Gui/FileTypeMainWindow_win.cpp +++ b/Gui/FileTypeMainWindow_win.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include NATRON_NAMESPACE_ENTER @@ -283,9 +283,10 @@ DocumentWindow::ddeExecute(MSG* message, return true; } - QRegExp regCommand( QString::fromUtf8("^\\[(\\w+)\\((.*)\\)\\]$") ); - if ( regCommand.exactMatch(command) ) { - executeDdeCommand( regCommand.cap(1), regCommand.cap(2) ); + QRegularExpression regCommand( QString::fromUtf8("^\\[(\\w+)\\((.*)\\)\\]$") ); + QRegularExpressionMatch match(regCommand.match(command)); + if ( match.hasMatch() ) { + executeDdeCommand( match.captured(1), match.captured(2) ); } *result = 0; @@ -345,15 +346,16 @@ void DocumentWindow::executeDdeCommand(const QString& command, const QString& params) { - QRegExp regCommand( QString::fromUtf8("^\"(.*)\"$") ); - bool singleCommand = regCommand.exactMatch(params); + QRegularExpression regCommand( QString::fromUtf8("^\"(.*)\"$") ); + QRegularExpressionMatch match(regCommand.match(params)); + bool singleCommand = match.hasMatch(); if ( ( 0 == command.compare(QString::fromUtf8("open"), Qt::CaseInsensitive) ) && singleCommand ) { - ddeOpenFile( regCommand.cap(1) ); + ddeOpenFile( match.captured(1) ); } else if ( ( 0 == command.compare(QString::fromUtf8("new"), Qt::CaseInsensitive) ) && singleCommand ) { - ddeNewFile( regCommand.cap(1) ); + ddeNewFile( match.captured(1) ); } else if ( ( 0 == command.compare(QString::fromUtf8("print"), Qt::CaseInsensitive) ) && singleCommand ) { - ddePrintFile( regCommand.cap(1) ); + ddePrintFile( match.captured(1) ); } else { executeUnknownDdeCommand(command, params); } diff --git a/Gui/GuiFwd.h b/Gui/GuiFwd.h index d939dbe92..3973f02e5 100644 --- a/Gui/GuiFwd.h +++ b/Gui/GuiFwd.h @@ -81,6 +81,7 @@ class QPoint; class QPointF; class QProgressDialog; class QRectF; +class QRegularExpression; class QScrollArea; class QSplitter; class QStyleOptionViewItem; diff --git a/Gui/NodeCreationDialog.cpp b/Gui/NodeCreationDialog.cpp index f73f142bd..a2f909620 100644 --- a/Gui/NodeCreationDialog.cpp +++ b/Gui/NodeCreationDialog.cpp @@ -37,8 +37,7 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include -#include -#include +#include #include #include CLANG_DIAG_ON(deprecated) @@ -151,12 +150,14 @@ CompleterLineEdit::filterText(const QString & txt) pattern.push_back(txt[i]); } pattern.push_back( QLatin1Char('*') ); - QRegExp expr(pattern, Qt::CaseInsensitive, QRegExp::WildcardUnix); + QRegularExpression expr(QRegularExpression::wildcardToRegularExpression(pattern)); + expr.setPatternOptions(QRegularExpression::CaseInsensitiveOption); #ifdef NODE_TAB_DIALOG_USE_MATCHED_LENGTH std::map matchOrdered; for (PluginsNamesMap::iterator it = _imp->names.begin(); it != _imp->names.end(); ++it) { - if ( expr.exactMatch(it->second.first) ) { + bool isMatch = expr.match(it->second.first).hasMatch(); + if ( isMatch ) { QStringList& matchedForLength = matchOrdered[expr.matchedLength()]; matchedForLength.push_front(it->second.second); } @@ -182,14 +183,6 @@ CompleterLineEdit::filterText(const QString & txt) } QPoint p = mapToGlobal( QPoint( 0, height() ) ); - //QDesktopWidget* desktop = QApplication::desktop(); - //QRect screen = desktop->screenGeometry(); - //double maxHeight = ( screen.height() - p.y() ) * 0.8; - //QFontMetrics fm = _imp->listView->fontMetrics(); - //maxHeight = std::min( maxHeight, ( rowCount * fm.height() * 1.2 + fm.height() ) ); - - // Position the text edit - // _imp->listView->setFixedSize(width(),maxHeight); _imp->listView->move(p); _imp->listView->show(); diff --git a/Gui/NodeGraph45.cpp b/Gui/NodeGraph45.cpp index b3e428c3f..7cb98e8b2 100644 --- a/Gui/NodeGraph45.cpp +++ b/Gui/NodeGraph45.cpp @@ -38,6 +38,7 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include +#include GCC_DIAG_UNUSED_PRIVATE_FIELD_ON CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) @@ -366,16 +367,14 @@ FindNodeDialog::updateFindResults(const QString& filter) return; } - Qt::CaseSensitivity sensitivity = _imp->caseSensitivity->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive; const NodesGuiList& activeNodes = _imp->graph->getAllActiveNodes(); - QRegExp exp(_imp->matchWhole->isChecked() ? filter : - ( QChar::fromLatin1('*') + filter + QChar::fromLatin1('*') ), - sensitivity, - QRegExp::Wildcard); + QRegularExpression exp(QRegularExpression::wildcardToRegularExpression( + _imp->matchWhole->isChecked() ? filter : ( QChar::fromLatin1('*') + filter + QChar::fromLatin1('*') ))); + exp.setPatternOptions(_imp->caseSensitivity->isChecked() ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption); if ( exp.isValid() ) { for (NodesGuiList::const_iterator it = activeNodes.begin(); it != activeNodes.end(); ++it) { - if ( (*it)->isVisible() && exp.exactMatch( QString::fromUtf8( (*it)->getNode()->getLabel().c_str() ) ) ) { + if ( (*it)->isVisible() && exp.match( QString::fromUtf8( (*it)->getNode()->getLabel().c_str() ) ).hasMatch() ) { _imp->nodeResults.push_back(*it); } } diff --git a/Gui/PreferencesPanel.cpp b/Gui/PreferencesPanel.cpp index 375e35871..9ea78edd1 100644 --- a/Gui/PreferencesPanel.cpp +++ b/Gui/PreferencesPanel.cpp @@ -37,6 +37,7 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include +#include #include #include #include @@ -819,7 +820,8 @@ PreferencesPanel::filterPlugins(const QString & txt) pattern.push_back(txt[i]); } pattern.push_back( QLatin1Char('*') ); - QRegExp expr(pattern, Qt::CaseInsensitive, QRegExp::WildcardUnix); + QRegularExpression expr(QRegularExpression::wildcardToRegularExpression(pattern)); + expr.setPatternOptions(QRegularExpression::CaseInsensitiveOption); std::list itemsToDisplay; for (PluginTreeNodeList::iterator it = _imp->pluginsList.begin(); it != _imp->pluginsList.end(); ++it) { if ( it->plugin && it->plugin->getLabelWithoutSuffix().contains(expr) ) { diff --git a/Gui/RenderStatsDialog.cpp b/Gui/RenderStatsDialog.cpp index a3bb460be..f3dea4710 100644 --- a/Gui/RenderStatsDialog.cpp +++ b/Gui/RenderStatsDialog.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include "Engine/Node.h" #include "Engine/Timer.h" @@ -1010,12 +1010,14 @@ RenderStatsDialogPrivate::updateVisibleRowsInternal(const QString& nameFilter, if ( useUnixWildcardsCheckbox->isChecked() ) { - QRegExp nameExpr(nameFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression nameExpr(QRegularExpression::wildcardToRegularExpression(nameFilter)); + nameExpr.setPatternOptions(QRegularExpression::CaseInsensitiveOption); if ( !nameExpr.isValid() ) { return; } - QRegExp idExpr(pluginIDFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression idExpr(QRegularExpression::wildcardToRegularExpression(pluginIDFilter)); + idExpr.setPatternOptions(QRegularExpression::CaseInsensitiveOption); if ( !idExpr.isValid() ) { return; } @@ -1028,8 +1030,8 @@ RenderStatsDialogPrivate::updateVisibleRowsInternal(const QString& nameFilter, continue; } - if ( ( nameFilter.isEmpty() || nameExpr.exactMatch( QString::fromUtf8( node->getLabel().c_str() ) ) ) && - ( pluginIDFilter.isEmpty() || idExpr.exactMatch( QString::fromUtf8( node->getPluginID().c_str() ) ) ) ) { + if ( ( nameFilter.isEmpty() || nameExpr.match( QString::fromUtf8( node->getLabel().c_str() ) ).hasMatch() ) && + ( pluginIDFilter.isEmpty() || idExpr.match( QString::fromUtf8( node->getPluginID().c_str() ) ).hasMatch() ) ) { if ( view->isRowHidden(i, rootIdx) ) { view->setRowHidden(i, rootIdx, false); } diff --git a/Gui/ScriptTextEdit.cpp b/Gui/ScriptTextEdit.cpp index 0f770a5ef..bd978f2ac 100644 --- a/Gui/ScriptTextEdit.cpp +++ b/Gui/ScriptTextEdit.cpp @@ -33,7 +33,7 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include -#include +#include #include CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) @@ -58,13 +58,13 @@ struct PyHighLightRule const QTextCharFormat &matchingFormat) { originalRuleStr = patternStr; - pattern = QRegExp(patternStr); + pattern = QRegularExpression(patternStr); nth = n; format = matchingFormat; } QString originalRuleStr; - QRegExp pattern; + QRegularExpression pattern; int nth; QTextCharFormat format; }; @@ -77,8 +77,8 @@ struct PySyntaxHighlighterPrivate QStringList braces; QHash basicStyles; QList rules; - QRegExp triSingleQuote; - QRegExp triDoubleQuote; + QRegularExpression triSingleQuote; + QRegularExpression triDoubleQuote; PySyntaxHighlighterPrivate(PySyntaxHighlighter* publicInterface) : publicInterface(publicInterface) @@ -125,13 +125,15 @@ void PySyntaxHighlighter::highlightBlock(const QString &text) { for (QList::Iterator it = _imp->rules.begin(); it != _imp->rules.end(); ++it) { - int idx = it->pattern.indexIn(text, 0); + QRegularExpressionMatch match(it->pattern.match(text)); + int idx = match.capturedStart(); while (idx >= 0) { // Get index of Nth match - idx = it->pattern.pos(it->nth); - int length = it->pattern.cap(it->nth).length(); + idx = match.capturedStart(it->nth); + int length = match.captured(it->nth).length(); setFormat(idx, length, it->format); - idx = it->pattern.indexIn(text, idx + length); + match = it->pattern.match(text, idx + length); + idx = match.capturedStart(); } } @@ -186,7 +188,7 @@ PySyntaxHighlighterPrivate::initializeRules() bool PySyntaxHighlighter::matchMultiline(const QString &text, - const QRegExp &delimiter, + const QRegularExpression &delimiter, const int inState, const QTextCharFormat &style) { @@ -201,18 +203,20 @@ PySyntaxHighlighter::matchMultiline(const QString &text, start = 0; add = 0; } else { - start = delimiter.indexIn(text); + QRegularExpressionMatch match(delimiter.match(text)); + start = match.capturedStart(); // Move past this match - add = delimiter.matchedLength(); + add = match.capturedLength(); } // As long as there's a delimiter match on this line... while (start >= 0) { // Look for the ending delimiter - end = delimiter.indexIn(text, start + add); + QRegularExpressionMatch match(delimiter.match(text, start + add)); + end = match.capturedStart(); // Ending delimiter on this line? if (end >= add) { - length = end - start + add + delimiter.matchedLength(); + length = end - start + add + match.capturedLength(); setCurrentBlockState(0); } else { // No= multi-line string @@ -221,7 +225,8 @@ PySyntaxHighlighter::matchMultiline(const QString &text, } // Apply formatting and look for next setFormat(start, length, style); - start = delimiter.indexIn(text, start + length); + match = delimiter.match(text, start + length); + start = match.capturedStart(); } // Return True if still inside a multi-line string, False otherwise if (currentBlockState() == inState) { diff --git a/Gui/ScriptTextEdit.h b/Gui/ScriptTextEdit.h index 25dc428c4..fa5fb15bf 100644 --- a/Gui/ScriptTextEdit.h +++ b/Gui/ScriptTextEdit.h @@ -57,7 +57,7 @@ class PySyntaxHighlighter private: virtual void highlightBlock(const QString &text) OVERRIDE FINAL; - bool matchMultiline(const QString &text, const QRegExp &delimiter, const int inState, const QTextCharFormat &style); + bool matchMultiline(const QString &text, const QRegularExpression &delimiter, const int inState, const QTextCharFormat &style); std::unique_ptr _imp; }; diff --git a/Gui/SequenceFileDialog.h b/Gui/SequenceFileDialog.h index e9a2f92f9..2432166a3 100644 --- a/Gui/SequenceFileDialog.h +++ b/Gui/SequenceFileDialog.h @@ -47,7 +47,6 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include -#include #include #include #include diff --git a/Gui/ViewerGL.cpp b/Gui/ViewerGL.cpp index 0b98c71d8..f51130259 100644 --- a/Gui/ViewerGL.cpp +++ b/Gui/ViewerGL.cpp @@ -1069,12 +1069,13 @@ NATRON_NAMESPACE_ANONYMOUS_ENTER static QStringList explode(const QString& str) { - QRegExp rx( QString::fromUtf8("(\\ |\\-|\\.|\\/|\\t|\\n)") ); //RegEx for ' ' '/' '.' '-' '\t' '\n' + QRegularExpression rx( QString::fromUtf8("(\\ |\\-|\\.|\\/|\\t|\\n)") ); //RegEx for ' ' '/' '.' '-' '\t' '\n' QStringList ret; int startIndex = 0; while (true) { - int index = str.indexOf(rx, startIndex); + QRegularExpressionMatch match(rx.match(str, startIndex)); + int index = match.capturedStart(); if (index == -1) { ret.push_back( str.mid(startIndex) );