[SOLVED] How to tell QRegExp to take the first result?
lets say we have a text
@start wekjrnwekjrnkjn end erweriuweirbiwur end
int result = filter.indexIn(html_source);
if(result != -1)
qDebug() << filter.cap(1);@
@wekjrnwekjrnkjn end erweriuweirbiwur@
that i want.. any ideas?
Regular Expressions are "greedy" be default. The string it picks perfectly matches your RegExp. The string you want matches as well, but it's shorter. So RegExp picks to longer one. That's the greediness.
The best way is to fix your RegExp, so it will only match the desired string.
Alternatively, you may try the QRegExp::setMinimal() function.
[quote author="MuldeR" date="1378476582"]
Alternatively, you may try the QRegExp::setMinimal() function.[/quote]
Thank you :)
exactly what i was looking for.
should have looked better the documentation