I will want to get a list of resaults by this condition of reg expression:
QRegExp rx(
"(https://)"
"(.*)"
"(\\.jpg)"
);
QStringList list;
int pos = 0;
while ((pos = rx.indexIn("jpegData_https://sfasdfsf_sadlfkjnsdlfjhn.jpgasodjfhasdfoho;usdoauhfsvc.asdfkpjhttps://adfklja32908jf0jmn01.jpg", pos)) != -1)
{
list << rx.cap(0);
pos += rx.matchedLength();
}
for(auto it : list)
{
qDebug() << it;
}
I have got it:
"pegData_https://sfasdfsf_sadlfkjnsdlfjhn.jpgasodjfhasdfoho;usdoauhfsvc.asdfkpjhttps://adfklja32908jf0jmn01.jpg"
I need to get:
https://sfasdfsf_sadlfkjnsdlfjhn.jpg
https://adfklja32908jf0jmn01.jpg
Please, help me, what is wrong in QRegExp condition?
By default, matching is greedy. Your desired behavior should simply be a case of calling setMinimal(true) on your QRegExp.
e.g.
QRegExp rx("(https://)(.*)(\\.jpg)");
rx.setMinimal(true);