本文整理汇总了C++中QRegularExpression::pattern方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpression::pattern方法的具体用法?C++ QRegularExpression::pattern怎么用?C++ QRegularExpression::pattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpression
的用法示例。
在下文中一共展示了QRegularExpression::pattern方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setRegularExpression
/*!
\internal
Sets \a re as the regular expression. It wraps the regexp that's actually used
between \\A and \\z, therefore forcing an exact match.
*/
void QRegularExpressionValidatorPrivate::setRegularExpression(const QRegularExpression &re)
{
Q_Q(QRegularExpressionValidator);
if (origRe != re) {
usedRe = origRe = re; // copies also the pattern options
usedRe.setPattern(QStringLiteral("\\A(?:") + re.pattern() + QStringLiteral(")\\z"));
emit q->regularExpressionChanged(re);
emit q->changed();
}
}
示例2: setRegExpFilter
void MultipleFilterProxy::setRegExpFilter(qint32 col, const QRegularExpression& matcher, qint32 role, bool match)
{
if (col < 0 || col >= m_dateRangeFilter.size())
return;
if (matcher.pattern().isEmpty() || !matcher.isValid())
return removeFilterFromColumn(col, role);
m_dateRangeFilter[col].remove(role);
m_boolFilter[col].remove(role);
m_regExpFilter[col][role] = std::make_pair(matcher, match);
invalidateFilter();
}
示例3: QStringList_indexOf
/*!
\fn int QStringList::indexOf(const QRegularExpression &re, int from) const
\overload
\since 5.0
Returns the index position of the first match of \a re in
the list, searching forward from index position \a from. Returns
-1 if no item matched.
\sa lastIndexOf()
*/
int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from)
{
if (from < 0)
from = qMax(from + that->size(), 0);
QString exactPattern = QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z");
QRegularExpression exactRe(exactPattern, re.patternOptions());
for (int i = from; i < that->size(); ++i) {
QRegularExpressionMatch m = exactRe.match(that->at(i));
if (m.hasMatch())
return i;
}
return -1;
}
示例4: IsInvalidExpression
bool syntax_highlighter::IsInvalidExpression(const QRegularExpression& expression)
{
return !expression.isValid() || expression.pattern().isEmpty();
}
示例5: highlightBlock
void MarkupHighlighter::highlightBlock(const QString &text)
{
if (FORMATTING.empty()){
qWarning() << "Not given any formatting, so not highlighting.";
return;
}
if (text.isEmpty()) return;
int start=0, end=0, highlightLength = 0;
QRegularExpression re;
QTextCharFormat textFormat;
for (QString exp : TOKENS.keys()){
setCurrentBlockState(0);
start = 0, end = 0;
re = QRegularExpression(exp);
if (!re.isValid()){
QString message = "Invalid regular expression \""
+ re.pattern() + "\" :" + re.errorString();
qFatal("%s", message.toStdString().data());
return;
}
if (previousBlockState() != 1)
start = re.match(text).capturedStart();
while (start >= 0){
QRegularExpressionMatch match = re.match(text, start);
end = match.capturedEnd();
if (end == -1 || (end == start && end != 0)){
setCurrentBlockState(1);
highlightLength = text.length();
} else {
highlightLength = match.capturedLength();
}
QTextCharFormat baseFormat = currentBlock().blockFormat().toCharFormat();
MarkupHighlighter::MarkupToken tok = TOKENS[exp];
if (!FORMATTING.contains(tok)){
qWarning() << "Could not find" << tok;
break;
}
const StyleProxy *styleProxy = FORMATTING[tok];
textFormat = styleProxy->toFormat(baseFormat);
setFormat(start, highlightLength, textFormat);
qDebug() << "highlightBlock";
qDebug() << "Formatting"
<< "token" << tok
<< "with regex=" << exp
<< ", string="
<< text.mid(start, highlightLength)
<< "\n"
<< " Bold?" << textFormat.font().bold() << "\n"
<< " Italic?" << textFormat.font().italic() << "\n"
<< " Size:" << textFormat.font().pointSize() << "\n"
<< " Background:" << textFormat.background().color();
start = re.match(text, end).capturedStart();
// This should not be 0 again. If it is, that means our search has
// come up empty.
if (start == 0)
start = -1;
}
}
}