Logo Search packages:      
Sourcecode: cb2bib version File versions

QString EQRegExp::cap ( int  nth = 0  ) 

Returns the text captured by the nth subexpression. The entire match has index 0 and the parenthesized subexpressions have indexes starting from 1 (excluding non-capturing parentheses).

        EQRegExp rxlen("(\\d+)(?:\\s*)(cm|inch)");
        int pos = rxlen.indexIn("Length: 189cm");
        if (pos > -1) {
            QString value = rxlen.cap(1); // "189"
            QString unit = rxlen.cap(2);  // "cm"
            // ...
        }

The order of elements matched by cap() is as follows. The first element, cap(0), is the entire matching string. Each subsequent element corresponds to the next capturing open left parentheses. Thus cap(1) is the text of the first capturing parentheses, cap(2) is the text of the second, and so on.

See also:
capturedTexts(), pos()

Definition at line 3941 of file eqregexp.cpp.

References capturedTexts().

{
    return capturedTexts().value(nth);
}


Generated by  Doxygen 1.6.0   Back to index