#include <iostream>
#include <regex>
std::string exptract_phone_number(const std::string& input)
{
const std::regex pattern(R"(^(8|\+?420)\s*\-?\s*(?:(\d{3})|\((\d{3})\))\s*\-?\s*(\d{7})$)");
std::smatch match;
return std::regex_match(input, match, pattern) ?
match[2].str() + match[3].str() + match[4].str() : "";
}
int main()
{
std::cout << exptract_phone_number("4207743822140") << std::endl;
std::cout << exptract_phone_number("+420-7743822140") << std::endl;
std::cout << exptract_phone_number("+420-(774)3822140") << std::endl;
std::cout << exptract_phone_number("+420774-3822140") << std::endl;
std::cout << exptract_phone_number("+420(774)-3822140") << std::endl;
std::cout << exptract_phone_number("+420-774-3822140") << std::endl;
std::cout << exptract_phone_number("+420-(774)-3822140") << std::endl;
std::cout << exptract_phone_number("87743822140") << std::endl;
std::cout << exptract_phone_number("8-7743822140") << std::endl;
std::cout << exptract_phone_number("8-(774)3822140") << std::endl;
std::cout << exptract_phone_number("8774-3822140") << std::endl;
std::cout << exptract_phone_number("8(774)-3822140") << std::endl;
std::cout << exptract_phone_number("8-774-3822140") << std::endl;
std::cout << exptract_phone_number("8-(774)-3822140") << std::endl;
}