TSG*_*TSG 4 qt clang qt-creator qregularexpression
我在 Qt Creator 中收到此警告:
不要创建临时 QRegularExpression 对象。使用静态 QRegularExpression 对象代替 [clazy-use-static-qregularexpression]
这是关于下面的代码片段:
QRegularExpression re("SEARCHING...",QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(frame);
if (match.hasMatch()) {
Run Code Online (Sandbox Code Playgroud)
这对我来说并不明显,我应该如何使用QRegularExpression
?
这是一条愚蠢的警告消息,您可以在此处找到其描述。这只是表明您不想每次输入该函数时都重新创建 QRegularExpression,因为表达式始终相同。所以做这样的事情应该有效:
static QRegularExpression re("SEARCHING...", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(frame);
if (match.hasMatch()) {
Run Code Online (Sandbox Code Playgroud)