I'm trying to get with a QRegularExpression all one-line comments starting by a '#'. I use globalMatch and and an iterator but it doesn't manage to find the "nested comments".
I use this regex : #[^\n]*
And with the following code :
const QString text { "Here # A test with some #comments" };
const QRegularExpression pattern { "#[^\n]*" };
QRegularExpressionMatchIterator it = pattern.globalMatch(text);
while (it.hasNext())
{
const QRegularExpressionMatch match = it.next();
qDebug() << match.capturedTexts()[0];
}
It founds only the global comment starting at "# A test" and not the second one. Is there a way to do that ?
Thanks !