Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Use raw strings to simplify regexes. #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/model/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ QStringList splitMessage(const QString& message, uint64_t maxLength)
void MessageProcessor::SharedParams::onUserNameSet(const QString& username)
{
QString sanename = username;
sanename.remove(QRegularExpression("[\\t\\n\\v\\f\\r\\x0000]"));
sanename.remove(QRegularExpression(R"([\t\n\v\f\r\x0000])"));
nameMention = QRegularExpression("\\b" + QRegularExpression::escape(username) + "\\b",
QRegularExpression::CaseInsensitiveOption);
sanitizedNameMention = QRegularExpression("\\b" + QRegularExpression::escape(sanename) + "\\b",
Expand Down
3 changes: 1 addition & 2 deletions src/widget/form/settings/aboutform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ void AboutForm::onUnstableVersion()
*/
QString AboutForm::createLink(QString path, QString text) const
{
return QString::fromUtf8(
"<a href=\"%1\" style=\"text-decoration: underline; color:%2;\">%3</a>")
return QString::fromUtf8(R"(<a href="%1" style="text-decoration: underline; color:%2;">%3</a>)")
.arg(path, style.getColor(Style::ColorPalette::Link).name(), text);
}

Expand Down
4 changes: 2 additions & 2 deletions src/widget/form/tabcompleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void TabCompleter::buildCompletionList()
// section
QString tabAbbrev = msgEdit->toPlainText()
.left(msgEdit->textCursor().position())
.section(QRegularExpression("[^\\w\\d\\$:@--_\\[\\]{}|`^.\\\\]"), -1, -1);
.section(QRegularExpression(R"([^\w\d\$:@--_\[\]{}|`^.\\])"), -1, -1);
// that section is then used as the completion regex
QRegularExpression regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegularExpression::escape(tabAbbrev)),
QRegularExpression regex(QString(R"(^[-_\[\]{}|`^.\\]*)").append(QRegularExpression::escape(tabAbbrev)),
QRegularExpression::CaseInsensitiveOption);

const QString ownNick = group->getSelfName();
Expand Down
3 changes: 1 addition & 2 deletions src/widget/tool/croppinglabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ void CroppingLabel::minimizeMaximumWidth()
void CroppingLabel::editingFinished()
{
hideTextEdit();
QString newText =
textEdit->text().trimmed().remove(QRegularExpression("[\\t\\n\\v\\f\\r\\x0000]"));
QString newText = textEdit->text().trimmed().remove(QRegularExpression(R"([\t\n\v\f\r\x0000])"));

if (origText != newText)
emit editFinished(textEdit->text());
Expand Down
Loading