#include <QCoreApplication>
#include <QRegExp>
#include <QDebug>
int main(int argc, char *argv[])
{
int pos1 = reg.indexIn(str, 5);
qDebug() << "F" << pos1 << reg.cap();
int pos2 = reg.lastIndexIn(str, 5);
qDebug() << "B" << pos2 << reg.cap();
return a.exec();
}
#include <QCoreApplication>
#include <QRegExp>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QRegExp reg("(.*)");
QString str = "_1234_4567_";
int pos1 = reg.indexIn(str, 5);
qDebug() << "F" << pos1 << reg.cap();
int pos2 = reg.lastIndexIn(str, 5);
qDebug() << "B" << pos2 << reg.cap();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Generates the following output:
F 5 "_4567_"
B 5 "_4567_"
F 5 "_4567_"
B 5 "_4567_"
To copy to clipboard, switch view to plain text mode
But I think output of reg.lastIndexIn(str, 5) must be like this:
B 0 "_1234_"
B 0 "_1234_"
To copy to clipboard, switch view to plain text mode
Hm....
Bookmarks