Exemple #1
0
Segment LineParser::expect(QRegExp &rx, QList<QString> expectedItems)
{
    int index = indexIn(rx, _line, _i);
    if (index != _i) {
        throw SegmentParseExpectedException(_line.atAsSegment(_i), expectedItems);
    }
    int start = _i;
    _i += rx.matchedLength();
    return _line.mid(start, rx.matchedLength());
}
Exemple #2
0
Segment LineParser::expect(const QRegExp &rx, std::initializer_list<QString> expectedItems)
{
    QRegExp rxcopy = rx;
    int index = indexIn(rxcopy, _line, _i);
    if (index != _i) {
        throw SegmentParseExpectedException(_line.atAsSegment(_i), expectedItems);
    }
    int start = _i;
    _i += rxcopy.matchedLength();
    return _line.mid(start, rxcopy.matchedLength());
}
Exemple #3
0
QStringList NRegExp::pregMatch(QString str)
{
    int pos = 0;
    QStringList list;

    while ((pos = indexIn(str, pos)) != -1) {
        list << cap(1);
        pos += matchedLength();
    }

    return list;
}