Filtering QStringList with QRegExp is not working[SOLVED]
-
Hey,
I tried to filter a QStringList having entries like these:
pic20150718_060126.jpg pic20150718_060626.jpg pic20150718_061126.jpg pic20150719_061126.jpg
For me just the part
20150718
is interesting.
So I used the expressionQRegExp(^pic20150718.+)
to filter.
If I now use theindexOf
-method of QStringList I always get "-1".What is the problem with that?
Thank you very much :-) -
Hi,
Can you show your code ?
Using
strList.indexOf(QRegExp("^pic20150718.*"));
works correctly.On a side note, if you are using Qt 5, you should rather use QRegularExpression
-
Thank you very much :-)
First I tried to insert the expression like this:
QString date = "20150718"; QString expr = "^pic"+date+".*"; QRegExp exp(expr);
This was not working, but now it works.
I cleaned the whole project and it seems like there was something wrong with the building process :-)