mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-19 08:37:22 -05:00
Add Matches() helper function
This commit is contained in:
parent
a7cf5769dd
commit
51d121bda2
|
|
@ -51,6 +51,23 @@ RegexConfig::GetRegularExpression(const std::string &expr) const
|
|||
return GetRegularExpression(QString::fromStdString(expr));
|
||||
}
|
||||
|
||||
bool RegexConfig::Matches(const QString &text, const QString &expression) const
|
||||
{
|
||||
auto regex = GetRegularExpression(expression);
|
||||
if (!regex.isValid()) {
|
||||
return false;
|
||||
}
|
||||
auto match = regex.match(text);
|
||||
return match.hasMatch();
|
||||
}
|
||||
|
||||
bool RegexConfig::Matches(const std::string &text,
|
||||
const std::string &expression) const
|
||||
{
|
||||
return Matches(QString::fromStdString(text),
|
||||
QString::fromStdString(expression));
|
||||
}
|
||||
|
||||
RegexConfig RegexConfig::PartialMatchRegexConfig()
|
||||
{
|
||||
RegexConfig conf;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ public:
|
|||
};
|
||||
QRegularExpression GetRegularExpression(const QString &) const;
|
||||
QRegularExpression GetRegularExpression(const std::string &) const;
|
||||
bool Matches(const QString &text, const QString &expression) const;
|
||||
bool Matches(const std::string &text,
|
||||
const std::string &expression) const;
|
||||
|
||||
static RegexConfig PartialMatchRegexConfig();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user