Qter 发表于 2021-6-17 16:11:29

Qt正则表达式替换

QRegExp toFindfileVersion("\"fileVersion\":(\\d+)");
            //QStringList listFileVersion;
            toFindfileVersion.indexIn(responseBody, 0);
            //int pos = 0;
            //while ((pos = toFindfileVersion.indexIn(responseBody, pos)) != -1)
            //{
            //    listFileVersion << toFindfileVersion.cap(1);
            //    pos += toFindfileVersion.matchedLength();
            //}
            responseBody.replace(toFindfileVersion, "\"fileVersion\":\"\\1\"");把下面的json串{"result":{"resultCode":"0","InfoList":[{"fileVersion":1514682649480225715},{"fileVersion":1514682649480221234}]}}
替换为{"result":{"resultCode":"0","InfoList":[{"fileVersion":"1514682649480225715"},{"fileVersion":"1514682649480221234"}]}}
页: [1]
查看完整版本: Qt正则表达式替换