Moved regexp for excluding digits to single place.

This commit is contained in:
23rd
2022-12-29 12:42:51 +03:00
parent 0eec470387
commit 297fd0f0c8
6 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -391,7 +391,7 @@ void CodeWidget::submitCode() {
const auto text = QString(
_code->getLastText()
).remove(
QRegularExpression("[^\\d]")
TextUtilities::RegExpDigitsExclude()
).mid(0, getData()->codeLength);
if (_sentRequest
@@ -487,7 +487,9 @@ EditContactScheme GetContactScheme(Scope::Type type) {
return Ui::FormatPhone(value);
};
result.postprocess = [](QString value) {
return value.replace(QRegularExpression("[^\\d]"), QString());
return value.replace(
TextUtilities::RegExpDigitsExclude(),
QString());
};
return result;
} break;
@@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "countries/countries_instance.h"
#include <QRegularExpression>
#include <QtCore/QLocale>
#include <locale>
#include <sstream>
@@ -136,7 +136,7 @@ void PhonePartInput::correctValue(
int &nowCursor) {
if (!now.isEmpty() && (_lastDigits != now)) {
_lastDigits = now;
_lastDigits.replace(QRegularExpression("[^\\d]"), QString());
_lastDigits.replace(TextUtilities::RegExpDigitsExclude(), QString());
updatePattern(_groupsCallback(_code + _lastDigits));
}
@@ -359,7 +359,7 @@ void PhoneInput::correctValue(
QString &now,
int &nowCursor) {
auto digits = now;
digits.replace(QRegularExpression("[^\\d]"), QString());
digits.replace(TextUtilities::RegExpDigitsExclude(), QString());
_pattern = _groupsCallback(digits);
QString newPlaceholder;
@@ -34,9 +34,7 @@ void SentCodeField::setChangedCallback(Fn<void()> changedCallback) {
QString SentCodeField::getDigitsOnly() const {
return QString(
getLastText()
).remove(
QRegularExpression("[^\\d]")
);
).remove(TextUtilities::RegExpDigitsExclude());
}
void SentCodeField::fix() {