Hi,
found param is not set in second search, so found is TRUE only if parameter is in ""
This should fix it: QString karamba::getString(QString w, QString &line, bool &found) { QRegExp rx( "\\W+" + w + "=\"([^\"]*)\"", false ); found = (rx.search(line)==-1)?false:true; if (rx.cap(1).isEmpty()) { rx = QRegExp(w + "=(\\S+)", false); found = (rx.search(line)==-1)?false:true; rx.search(line); return rx.cap(1); } else { return rx.cap(1); }
}
Log in to post a comment.
Hi,
found param is not set in second search, so found is TRUE only if parameter is in ""
This should fix it:
QString karamba::getString(QString w, QString &line, bool &found)
{
QRegExp rx( "\\W+" + w + "=\"([^\"]*)\"", false );
found = (rx.search(line)==-1)?false:true;
if (rx.cap(1).isEmpty())
{
rx = QRegExp(w + "=(\\S+)", false);
found = (rx.search(line)==-1)?false:true;
rx.search(line);
return rx.cap(1);
}
else
{
return rx.cap(1);
}
}