QT regularExpressions retrieve numbers

前端 未结 2 1769
旧时难觅i
旧时难觅i 2021-01-25 01:15

I\'ve to split simple QStrings of the form \"number number number\",for example \" 2323 432 1223\". The code i use is

QString line;
QRegularExpression re(\"(\\         


        
2条回答
  •  终归单人心
    2021-01-25 01:53

    If the usage of regular expressions isn't mandatory, you could also use QString's split()-function.

    QString str("2323 432 1223");
    QStringList list = str.split(" ");
    for(int i = 0; i < list.length(); i++){
        qDebug() << list.at(i);
    }
    

提交回复
热议问题