PDA

View Full Version : QRegExp



tebessum
3rd August 2008, 15:55
"TOTAL : <COUNT> LINE."

I want split only <COUNT> with QRegExp, how can do this ?

bvs
3rd August 2008, 18:44
Try the following code:



QString line1("TOTAL: 534 LINE.");
QRegExp rx("TOTAL: (\\d+) LINE.");
if (rx.indexIn(line1) != -1) {
qDebug() << "count in line1 = " << rx.cap(1);
}

The important thing are the parentheses around "(\\d+)", which capture the matching text. You can access this text with cap() as shown.

Cheers,
Burkhard