QmlDesigner: Simplyfy trimNonAsciifromFront

Use STL instead of QRegularExpression.

Change-Id: I30396160706dc86aa6bbf82635681e8938a65352
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
Marco Bubke
2025-02-14 14:49:14 +01:00
parent 0468f94753
commit 3e343dda13

View File

@@ -40,11 +40,11 @@ QString filterInvalidLettersAndCapitalizeAfterInvalidLetter(QStringView id)
return result;
}
void trimNonAsciifromFront(QString &str)
void trimNonAsciifromFront(QString &text)
{
static const QRegularExpression lettersRegEx("[a-zA-Z]");
const int letterIndex = str.indexOf(lettersRegEx);
str = letterIndex == -1 ? QString() : str.sliced(letterIndex).trimmed();
auto found = std::ranges::find_if(text, isAsciiLetter);
text.erase(text.begin(), found);
}
void lowerFirstLetter(QString &id)