Logo Search packages:      
Sourcecode: qt-x11-free version File versions

int QRegExp::searchRev ( const QString str,
int  offset,
CaretMode  caretMode 
) 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:
search() exactMatch()

Definition at line 3697 of file qregexp.cpp.

References QString::length().

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

    while ( offset >= 0 ) {
      eng->match( str, offset, priv->min, TRUE, caretIndex(offset, caretMode),
                priv->captured );
      if ( priv->captured[0] == offset )
          return offset;
      offset--;
    }
    return -1;
}


Generated by  Doxygen 1.6.0   Back to index