Hmm... this indeed is strange but I can believe the behaviour is intentional.
You may obtain the result you want using this code:
#include <QString>
#include <QRegExp>
int main(int argc, char **argv){
QString string
= "coolfilename02.153.ext";
QRegExp rx
("([0-9]+)(\\.[^\\.]*)$");
rx.setMinimal(true);
rx.indexIn(string);
qDebug
(qPrintable
(QString("0: %1 1: %2 2: %3").
arg(rx.
cap(0)).
arg(rx.
cap(1)).
arg(rx.
cap(2))));
return 0;
}
#include <QString>
#include <QRegExp>
int main(int argc, char **argv){
QString string = "coolfilename02.153.ext";
QRegExp rx("([0-9]+)(\\.[^\\.]*)$");
rx.setMinimal(true);
rx.indexIn(string);
qDebug(qPrintable(QString("0: %1 1: %2 2: %3").arg(rx.cap(0)).arg(rx.cap(1)).arg(rx.cap(2))));
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks