当然可以投机取巧了,比如 QString pattern("(.*),(.*)"); QRegExp rx(pattern); QString line = in.readLine(); //----process_line(line); line.replace("points.push(new GLatLng(",""); line.replace("));",""); int pos = line.indexOf(rx); // 0, position of the first match.【ps】如果不做替换该怎么写表达式呢?谢谢啊……
QString pattern("([-]*[0-9]{2,3}.[0-9]+),([-]*[0-9]{2,3}.[0-9]+)");QRegExp rx(pattern);QString line = "points.push(new GLatLng(64.084539881516,-21.953430550266));";int pos = line.indexOf(rx); // 0, position of the first match.qreal lat = rx.cap(1).toDouble();qreal lng = rx.cap(2).toDouble(); 非常感谢,按wxj120bw的办法搞定了!