Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a588eeb6 authored by Laurent Montel's avatar Laurent Montel 😁

Use regularexpression

parent dcc7a52e
......@@ -50,6 +50,8 @@ void KDebugSettingUtilTest::shouldParseKdeLoggingLine_data()
QTest::newRow("comment-2") << QStringLiteral("#log linux") << QString() << QString() << false;
QTest::newRow("validLineWithParentheses") << QStringLiteral("log linux (foo)") << QStringLiteral("linux (foo)") << QStringLiteral("log") << true;
QTest::newRow("validLineWithParenthesesAndCategories") << QStringLiteral("log linux (foo) [WARNING]") << QStringLiteral("linux (foo) [WARNING]") << QStringLiteral("log") << true;
QTest::newRow("linewithcomment") << QStringLiteral("log linux#comment about linux") << QStringLiteral("linux") << QStringLiteral("log") << true;
}
......
......@@ -91,19 +91,21 @@ KdeLoggingCategory KDebugSettingsUtil::parseLineKdeLoggingCategory(QString line)
qCWarning(KDEBUGSETTINGS_LOG) << "No space:" << line << endl;
return category;
}
#if 1
#if 0
//log linux (foo)
const QString logName = line.left(space);
const QString description = line.mid(space).simplified();
#else
QString logName;
QString description;
static const QRegularExpression regularExpressionUser(QStringLiteral("^(.*)\\s+(.*)$"));
static const QRegularExpression regularExpressionUser(QStringLiteral("^([\\w._-]+)\\s*(.*)$"));
QRegularExpressionMatch match = regularExpressionUser.match(line);
if (match.hasMatch()) {
logName = match.captured(1);
description = match.captured(2);
qDebug() << " logName"<<logName<<" description " << description << " line " << line;
//qDebug() << " logName"<<logName<<" description " << description << " line " << line;
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment