【发布时间】:2021-10-05 04:25:24
【问题描述】:
我正在将 Qt5 应用程序移植到 Qt6。我想尽快离开 Qt6 的 Qt5CoreCompat 模块。我的问题是 QRegExp 类应该替换为 QRegularExpression 类。大多数补丁都比较简单,但我如何在 Qt6 中移植QRegExp::exactMatch()。以下是应用程序中的一些代码:
QRegExp version(QLatin1String("(.+)_v(\\d+)"));
if (version.exactMatch(completeBaseName/*QString*/))
{
// some code
}
我在QRegularExpressionMatch 类中看不到这样做的方法。我想解决方案可能是这样的:
QRegularExpression version(QLatin1String("(.+)_v(\\d+)"));
QRegularExpressionMatch match = version.match(completeBaseName);
if (match.hasMatch())
{
// Find exact match or not
}
我想要和以前一样的行为。
【问题讨论】: