#include <iostream>
#include <string>
#include <regex>
bool is_hexadecimal(const std::string& str) {
return std::regex_match( str, std::regex("^(0x|0X)?[A-Fa-f0-9]+$") );
}
int main() {
std::string str;
std::cout << "Please enter hexadecimal number: ";
std::cin >> str;
if (is_hexadecimal(str)) {
std::cout << "The entered string is hexadecimal\n";
else {
std::cout << "The entered string is not hexadecimal \n";
return 0;
#include <iostream>
#include <string>
#include <regex>
bool is_hexadecimal(const std::string& str) {
return std::regex_match( str, std::regex("^(0x|0X)?[A-Fa-f0-9]+$") );
}
int main() {
std::string str;
std::cout << "Please enter hexadecimal number: ";
std::cin >> str;
if (is_hexadecimal(str)) {
std::cout << "The entered string is hexadecimal\n";
}
else {
std::cout << "The entered string is not hexadecimal \n";
}
return 0;
}