Qtの基礎 - 正規表現
ナビゲーションに移動
検索に移動
概要
QRegularExpressionクラス (推奨)
QRegExpクラス (非推奨)
エラー
Qt 6において、QRegExp
クラスを使用する場合、以下に示すエラーが発生する。
QRegExp was not declared in this scope
このエラーは、Qt 6ではQRegExp
クラスが非推奨となり、QRegularExpression
クラスを使用する必要がある。
#include <QRegularExpression>
static QRegularExpression RegEx("[+-]");
QString coordinate = "111-222+333";
QStringList parts = coordinate.split(RegEx, Qt::SkipEmptyParts);
QRegularExpression
クラスは、より強力で効率的な正規表現エンジンを提供しており、QRegExp
クラスと比較していくつかの利点がある。