QRegExp rx;rx.setPattern("(?:access_token=(\\w+))(?:expires_in=(\\d+))");if (y = rx.indexIn(s) ) { sAccess_token = rx.cap(1); sExpires_in = rx.cap(2); }
C++ (Qt)QRegExp rx("access_token=([a-z\\d]+)&expires_in=(\\d+)");rx.setMinimal(true);
QString tmp = "https://oauth.vk.com/blank.html#access_token=17a6ab0190a8ad75c2f3dffa713c3708c6943dc1562cdee85252f33a8fdabdbc803d33e7aa841bc4e9b70&expires_in=86400&user_id=14266994";int i1 = (tmp.indexOf("token="));int i2 = (tmp.indexOf("&expires_in="));int i3 = (tmp.indexOf("&user_id="));QString sAccess_token = tmp.mid(i+6, i2);QString sExpires_in = tmp.mid(i2+12, i3);
C++ (Qt)QRegExp rx(".+(?:access_token=([0-9a-f]+)(?:&|$)).*(?:expires_in=(\\d+)(?:&|$)).*");if (rx.exactMatch(s)) { sAccess_token = rx.cap(1); sExpires_in = rx.cap(2); }