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()<<re.cap(1)<<" "<<re.cap(2); pos += re.matchedLength(); } //QRegExp支持的类似Perl的正则表达式语法 应当用功能更强大的QRegularExpression类
原文:https://www.cnblogs.com/azbane/p/12100417.html