Originally Posted by
hassinoss
i tried it but it doesn't work
Wysota's suggestion is not quite right but it really doesn't matter because what you asked for was not what you wanted anyway.
You actually wanted to split the expression into tokens. This a non-trivial exercise in general cases, but for your specific case this works:
QString formule
= "Cos([Temperature1]*25)+58" ;
// The incredibly simple
qDebug() << list;
// or the more involved but more flexible
list.clear();
int pos = 0;
while ((pos = re.indexIn(formule, pos)) != -1) {
list << re.cap(0);
pos += re.matchedLength();
};
qDebug() << list;
QString formule = "Cos([Temperature1]*25)+58" ;
// The incredibly simple
QStringList list = formule.split(QRegExp("[()]"));
qDebug() << list;
// or the more involved but more flexible
list.clear();
const QRegExp re("[^()]+");
int pos = 0;
while ((pos = re.indexIn(formule, pos)) != -1) {
list << re.cap(0);
pos += re.matchedLength();
};
qDebug() << list;
To copy to clipboard, switch view to plain text mode
Bookmarks