Logo Search packages:      
Sourcecode: cb2bib version File versions

int EQRegExp::lastIndexIn ( const QString &  str,
int  offset = -1,
CaretMode  caretMode = CaretAtZero 
) const

Attempts to find a match backwards in str from position offset. If offset is -1 (the default), the search starts at the last character; if -2, at the next to last character; etc.

Returns the position of the first match, or -1 if there was no match.

The caretMode parameter can be used to instruct whether {^} should match at index 0 or at offset.

Although const, this function sets matchedLength(), capturedTexts() and pos().

Warning:
Searching backwards is much slower than searching forwards.
See also:
indexIn(), exactMatch()

Definition at line 3803 of file eqregexp.cpp.

{
    prepareEngineForMatch(priv, str);
    if (offset < 0)
        offset += str.length();
    if (offset < 0 || offset > str.length()) {
        priv->matchState.captured.fill(-1);
        return -1;
    }

    while (offset >= 0) {
        priv->matchState.match(str, offset, priv->min, true, caretIndex(offset, caretMode));
        if (priv->matchState.captured.at(0) == offset)
            return offset;
        --offset;
    }
    return -1;
}


Generated by  Doxygen 1.6.0   Back to index