The code below demonstrates how to parse GUID in C++ using a regular expression:
#include <iostream>
#include <string>
#include <regex>
int main()
{
static const std::wregex regex(L"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
std::wstring sample = L"850fe1da-0ea6-c1a8-9810-0c1cece30698";
std::match_results<std::wstring::const_iterator> match;
if (std::regex_match(sample, match, regex))
{
std::wcout << L"matches" << std::endl;
}
else
{
std::wcout << L"does not match" << std::endl;
}
return 0;
}