I want to regex match an ISBN number of the format: 1234-5678-9x ie. 4 digits [hyphen] 4 digits [hyphen] 1 digit 1 alphanum but the following program rejects valid output. Any help much appreciated (also, if not too much trouble, please tell me where and how I'm wrong as well):
Code:
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::regex ISBN ("[0-9][{4}][-][0-9][{4}][-][0-9][::alnum::]");
std::cout << "Enter ISBN number \n";
std::string input{};
getline(std::cin, input);
if (std::regex_match(input, ISBN))
{
std::cout << "Success \n";
}
else
{
std::cout << "Fail \n";
}
}
Thank you