У меня есть строка:
string str = "C:/Riot Games/League of Legends/LeagueClientUx.exe" "--riotclient-auth-token=yvjM3_sRqdaFoETdKSt1bQ" "--riotclient-app-port=53201" "--no-rads" "--disable-self-update" "--region=EUW" "--locale=en_GB" "--remoting-auth-token=13bHJUl7M_u_CtoR7v8XeA" "--respawn-command=LeagueClient.exe" "--respawn-display-name=League of Legends" "--app-port=53230" "--install-directory=C:\Riot Games\League of Legends" "--app-name=LeagueClient" "--ux-name=LeagueClientUx" "--ux-helper-name=LeagueClientUxHelper" "--log-dir=LeagueClient Logs" "--crash-reporting=crashpad" "--crash-environment=EUW1" "--crash-pipe=\\.\pipe\crashpad_12076_CFZRMYHTBJGPBIUH" "--app-log-file-path=C:/Riot Games/League of Legends/Logs/LeagueClient Logs/2020-07-13T13-33-41_12076_LeagueClient.log" "--app-pid=12076" "--output-base-dir=C:\Riot Games\League of Legends" "--no-proxy-server";
Я хочу получить номер порта и токен удаленной аутентификации, и я делаю это с помощью следующего кода:
#include <regex>
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
string PrintMatch(std::string str, std::regex reg) {
smatch matches;
while (regex_search(str,matches,reg))
{
cout << matches.str(1) << endl;
break;
}
return matches.str(1);
}
int main() {
string str = "C:/Riot Games/League of Legends/LeagueClientUx.exe" "--riotclient-auth-token=yvjM3_sRqdaFoETdKSt1bQ" "--riotclient-app-port=53201" "--no-rads" "--disable-self-update" "--region=EUW" "--locale=en_GB" "--remoting-auth-token=13bHJUl7M_u_CtoR7v8XeA" "--respawn-command=LeagueClient.exe" "--respawn-display-name=League of Legends" "--app-port=53230" "--install-directory=C:\Riot Games\League of Legends" "--app-name=LeagueClient" "--ux-name=LeagueClientUx" "--ux-helper-name=LeagueClientUxHelper" "--log-dir=LeagueClient Logs" "--crash-reporting=crashpad" "--crash-environment=EUW1" "--crash-pipe=\\.\pipe\crashpad_12076_CFZRMYHTBJGPBIUH" "--app-log-file-path=C:/Riot Games/League of Legends/Logs/LeagueClient Logs/2020-07-13T13-33-41_12076_LeagueClient.log" "--app-pid=12076" "--output-base-dir=C:\Riot Games\League of Legends" "--no-proxy-server";
regex reg("([0-9][0-9][0-9][0-9][0-9])");
string port = PrintMatch(str, reg);
regex reg1("(remoting-auth-token=[^\d]*)");
string output = PrintMatch(str, reg1);
}
´
Дает мне следующий результат:
53201
remoting-auth-token=13bHJUl7M_u_CtoR7v8XeA--respawn-comman
Количество символов в номере порта (53201) не меняется, так что я получаю это успешно. Однако токен удаленной аутентификации изменяется, поэтому я не знаю, как я могу успешно ее получить также при изменении длины.
Я хочу получить эту часть из токена удаленной аутентификации: «13bHJUl7M_u_CtoR7v8XeA», чтобы я мог сохранить это в переменной для использования в моем приложении, точно так же, как я сделал с номером порта.
Жду вашего ответа! :)