Logo Search packages:      
Sourcecode: cb2bib version File versions

int EQRegExp::pos ( int  nth = 0  ) 

Returns the position of the nth captured text in the searched string. If nth is 0 (the default), pos() returns the position of the whole match.


        EQRegExp rx("/([a-z]+)/([a-z]+)");
        rx.indexIn("Output /dev/null");   // returns 7 (position of /dev/null)
        rx.pos(0);                        // returns 7 (position of /dev/null)
        rx.pos(1);                        // returns 8 (position of dev)
        rx.pos(2);                        // returns 12 (position of null)

For zero-length matches, pos() always returns -1. (For example, if cap(4) would return an empty string, pos(4) returns -1.) This is a feature of the implementation.

See also:
cap(), capturedTexts()

Definition at line 3966 of file eqregexp.cpp.

    if (nth < 0 || nth >= priv->matchState.captured.size() / 2)
        return -1;
        return priv->matchState.captured.at(2 * nth);

Generated by  Doxygen 1.6.0   Back to index