int offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
+ bool checkSubjectString = true,
const QRegularExpressionMatchPrivate *previous = 0) const;
int captureIndexForName(const QString &name) const;
Performs a match of type \a matchType on the given \a subject string with
options \a matchOptions and returns the QRegularExpressionMatchPrivate of
the result. It also advances a match if a previous result is given as \a
- previous.
+ previous. The \a subject string goes a Unicode validity check if
+ \a checkSubjectString is true (PCRE doesn't like illegal UTF-16 sequences).
Advancing a match is a tricky algorithm. If the previous match matched a
non-empty string, we just do an ordinary match at the offset position.
int offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
+ bool checkSubjectString,
const QRegularExpressionMatchPrivate *previous) const
{
if (offset < 0)
else if (matchType == QRegularExpression::PartialPreferFirstMatch)
pcreOptions |= PCRE_PARTIAL_HARD;
+ if (!checkSubjectString)
+ pcreOptions |= PCRE_NO_UTF16_CHECK;
+
bool previousMatchWasEmpty = false;
if (previous && previous->hasMatch &&
(previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) {
Q_ASSERT(isValid);
Q_ASSERT(hasMatch || hasPartialMatch);
+ // Note the "false" passed for the check of the subject string:
+ // if we're advancing a match on the same subject,
+ // then that subject was already checked at least once (when this object
+ // was created, or when the object that created this one was created, etc.)
QRegularExpressionMatchPrivate *nextPrivate = regularExpression.d->doMatch(subject,
capturedOffsets.at(1),
matchType,
matchOptions,
+ false,
this);
return QRegularExpressionMatch(*nextPrivate);
}