wirasto
21st April 2013, 20:40
I want clean any comments in my source code. I tried like this. But I think not work properly :(
QRegExp ex("//[^\n]*"); //single line comment
QFile f("/home/wirasto/coba.php");
if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {
QTextStream in(&f);
while (!in.atEnd()) {
QString str=in.readLine();
qDebug() << str.replace(ex, "");
}
}
And I think for multiline comments will be more difficult :rolleyes:
I already found this (http://lists.trolltech.com/qt-interest/2005-07/thread01235-0.html) thread.
QRegExp ex("//[^\n]*"); //single line comment
QFile f("/home/wirasto/coba.php");
if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {
QTextStream in(&f);
while (!in.atEnd()) {
QString str=in.readLine();
qDebug() << str.replace(ex, "");
}
}
And I think for multiline comments will be more difficult :rolleyes:
I already found this (http://lists.trolltech.com/qt-interest/2005-07/thread01235-0.html) thread.