parseGCodes 、parseMCodes
QList<int> GcodePreprocessorUtils::parseGCodes(QString command) { static QRegExp re("[Gg]0*(\\d+)"); QList<int> codes; int pos = 0; while ((pos = re.indexIn(command, pos)) != -1) { codes.append(re.cap(1).toInt()); pos += re.matchedLength(); } return codes; } QList<int> GcodePreprocessorUtils::parseMCodes(QString command) { static QRegExp re("[Mm]0*(\\d+)"); QList<int> codes; int pos = 0; while ((pos = re.indexIn(command, pos)) != -1) { codes.append(re.cap(1).toInt()); pos += re.matchedLength(); } return codes; }