I have to extract single-line comments from qmake
project file.
Rules are simple: comment begins with #
symbol and begin with line-break \n
.
So i'm read some documentation about QRegExp
, and write such code to print all comments in qmake file:
QRegExp re ("#(.*)\n$");
re.setMinimal (true);
int comment_index = 0;
while ((comment_index = _project_contents.indexOf (comment_expr, comment_index)) != -1)
{
QString comment_text = comment_expr.cap (0);
qDebug() << "Comment 1" << comment_text;
}
But it is not work correctly - just all contents of project file has been printed. Where is my mistake? as i understand from docs, this should work, but it doesn't.
P.S. I'm a newbie in regexes, so please don't beat me :)