本文整理汇总了C++中QRegularExpressionMatch::capturedView方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpressionMatch::capturedView方法的具体用法?C++ QRegularExpressionMatch::capturedView怎么用?C++ QRegularExpressionMatch::capturedView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpressionMatch
的用法示例。
在下文中一共展示了QRegularExpressionMatch::capturedView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playground
void playground(QApplication& a)
{
std::vector<int> l1 = { 0,1,3,6,9,11 };
auto fromItem = std::upper_bound(l1.begin(), l1.end(), 2
, [](const auto &a, const auto &b)
{
return a > b;
});
return;
TextColorize::List _coloredTextParts;
auto match = [&_coloredTextParts](const QString& text, Part::List& parts)
{
QRegularExpression::PatternOptions options;
/*if (tc.caseSensitive == false)
options |= QRegularExpression::PatternOption::CaseInsensitiveOption;
*/
QString rePattern;
foreach(TextColorize ctp, _coloredTextParts) {
QString pattern;
if (ctp.caseSensitive == false)
pattern += "(?i)";
pattern += ctp.text;
pattern.prepend("(").append(")");
if(ctp.wordOnly)
pattern.prepend("(?:^|[^\\w])").append("(?:[^\\w]|$)");
rePattern += "|" + pattern;
}
rePattern = rePattern.mid(1);
QRegularExpression re(rePattern, options);
QRegularExpressionMatchIterator it = re.globalMatch(text);
int nonMatchedStart = 0;
bool hasMatches = it.hasNext();
while (it.hasNext()) {
QRegularExpressionMatch match = it.next();
int matchedGroup = match.lastCapturedIndex();
while (match.capturedTexts().at(matchedGroup).length() && --matchedGroup);
qDebug()
<< match.capturedTexts() << " - "
<< match.capturedView() << " - "
<< match.hasPartialMatch() << " - "
<< matchedGroup;
int nonMatechedEnd = match.capturedStart(0);
int nonMatchedLength = nonMatechedEnd - nonMatchedStart;
//auto& ct = _coloredTextParts[match.lastCapturedIndex() - 1];
auto& ct = _coloredTextParts[0];
if (nonMatchedLength)
;// parts.push_back({ text.mid(nonMatchedStart, nonMatchedLength), nullptr });
parts.push_back({ text.mid(match.capturedStart(0), match.capturedLength(0)), match.lastCapturedIndex() });
nonMatchedStart = match.capturedEnd(0);
}
if (nonMatchedStart < text.length())
parts.push_back({ text.mid(nonMatchedStart), false });
return hasMatches;
};