Replace usage of QRegularExpression::anchoredPattern with `^` and `$`

Using `^` and `$` is shorter than `QRegularExpression::anchoredPattern`,
and even allows us in one case to get rid of a trailing `.*`.
7220-lua-add-a-general-purpose-lexical-parser
jvoisin 2 years ago
parent 94259317bb
commit c90d22f3b2

@ -205,7 +205,7 @@ void Launcher::GraphicsPage::saveSettings()
int cHeight = 0;
if (standardRadioButton->isChecked())
{
QRegularExpression resolutionRe(QRegularExpression::anchoredPattern(QString("(\\d+) x (\\d+).*")));
QRegularExpression resolutionRe("^(\\d+) x (\\d+)");
QRegularExpressionMatch match = resolutionRe.match(resolutionComboBox->currentText().simplified());
if (match.hasMatch())
{

@ -20,8 +20,7 @@ Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString&
label->setText(text);
// Line edit
QValidator* validator
= new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
QValidator* validator = new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9_]*$"), this);
mLineEdit = new LineEdit(this);
mLineEdit->setValidator(validator);
mLineEdit->setCompleter(nullptr);

@ -30,7 +30,7 @@ bool Wizard::IniSettings::readFile(QTextStream& stream)
// Look for a square bracket, "'\\["
// that has one or more "not nothing" in it, "([^]]+)"
// and is closed with a square bracket, "\\]"
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
// Find any character(s) that is/are not equal sign(s), "[^=]+"
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
@ -75,7 +75,7 @@ bool Wizard::IniSettings::writeFile(const QString& path, QTextStream& stream)
// Look for a square bracket, "'\\["
// that has one or more "not nothing" in it, "([^]]+)"
// and is closed with a square bracket, "\\]"
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
// Find any character(s) that is/are not equal sign(s), "[^=]+"
// followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"

@ -47,7 +47,7 @@ QStringList Config::LauncherSettings::subKeys(const QString& key)
bool Config::LauncherSettings::writeFile(QTextStream& stream)
{
QString sectionPrefix;
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("([^/]+)/(.+)$"));
QRegularExpression sectionRe("^([^/]+)/(.+)$");
QMultiMap<QString, QString> settings = SettingsBase::getSettings();
QMapIterator<QString, QString> i(settings);

@ -42,7 +42,7 @@ namespace Config
QString sectionPrefix;
QRegularExpression sectionRe(QRegularExpression::anchoredPattern("^\\[([^]]+)\\]"));
QRegularExpression sectionRe("^\\[([^]]+)\\]$");
QRegularExpression keyRe("^([^=]+)\\s*=\\s*(.+)$");
while (!stream.atEnd())

Loading…
Cancel
Save