Logo Search packages:      
Sourcecode: cb2bib version File versions

bool EQRegExp::exactMatch ( const QString &  str  )  const

Returns true if str is matched exactly by this regular expression; otherwise returns false. You can determine how much of the string was matched by calling matchedLength().

For a given regexp string R, exactMatch("R") is the equivalent of indexIn("^R$") since exactMatch() effectively encloses the regexp in the start of string and end of string anchors, except that it sets matchedLength() differently.

For example, if the regular expression is {blue}, then exactMatch() returns true only for input blue. For inputs bluebell, blutak and lightblue, exactMatch() returns false and matchedLength() will return 4, 3 and 0 respectively.

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

See also:
indexIn(), lastIndexIn()

Definition at line 3723 of file eqregexp.cpp.

{
    prepareEngineForMatch(priv, str);
    priv->matchState.match(str, 0, priv->min, true, 0);
    if (priv->matchState.captured.at(1) == str.length()) {
        return true;
    } else {
        priv->matchState.captured[0] = 0;
        priv->matchState.captured[1] = priv->matchState.oneTestMatchedLen;
        return false;
    }
}


Generated by  Doxygen 1.6.0   Back to index