You can split a QString using QString::split and use QRegExp for capture part of string matching a pattern
// Split in lines
QRegExp re
("([+-]\\d*)([+-]\\d*)");
if (re.exactMatch(line)) {
a1 = rx.cap (1);
a2 = rx.cap (2);
// do something with a1 and a2
}
else {
bb = line;
// do something with bb
}
}
// Split in lines
QStringList lines = aaa.split('\n');
QRegExp re("([+-]\\d*)([+-]\\d*)");
Q_FOREACH (QString line, lines) {
if (re.exactMatch(line)) {
a1 = rx.cap (1);
a2 = rx.cap (2);
// do something with a1 and a2
}
else {
bb = line;
// do something with bb
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks