正则表达式匹配二维点序列

    QString pattern("\\s*\\(\\s*(\\d+\\.?\\d*)\\s*,\\s*(\\d+\\.?\\d*)\\s*\\)\\s*;");
    QString srPointf("(1.1  , 2.2);(3.3, 4.4 ); (5.5, 6.6); (7, 8);");

    QRegExp re(pattern);
    re.indexIn(srPointf);
    qDebug()<<re.captureCount();
    int pos = 0;
    while((pos = re.indexIn(srPointf, pos)) != -1){
        qDebug()<1)<<"  "<2);
        pos += re.matchedLength();
    }


//QRegExp支持的类似Perl的正则表达式语法

应当用功能更强大的QRegularExpression类

 

你可能感兴趣的:(正则表达式匹配二维点序列)