PDA

View Full Version : Comments Cleaner



wirasto
21st April 2013, 19: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.

wysota
21st April 2013, 22:43
http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments