I have a URL in wstring format in C++, e.g.:
http://stackoverflow.com?Country=US&City=Seattle&State=WA
I want to get rid of Country query param from the above string. Country query param can be the first query param or could be the last too.
wstring ManagementUrl = L"http://stackoverflow.com?Country=US&City=Seattle&State=WA"
wstring queryParam = L"&Country=US";
wstring queryParam1 = L"Country=US";
string::size_type urlLength = ManagementUrl.length();
string::size_type queryLength = queryParam.length();
string::size_type queryLength1 = queryParam1.length();
size_t index = ManagementUrl.find(queryParam);
if (index != std::wstring::npos)
{
wstrLink.erase(index, queryLength);
}
size_t index1 = ManagementUrl.find(queryParam1);
if (index != std::wstring::npos)
{
wstrLink.erase(index, queryLength1);
}
Is there a better way to do this?