Matching single digit with std::regex_match

Viewed 5714

According to this reference, I should be able to match a single digit with

std::regex e1 ("\\d");  

However, when I run the following test code I get a regex exception.

#include <iostream>
#include <string>
#include <regex>

int main()
{
  std::regex r("\\d");
  std::string s("9");
  if (std::regex_match(s, r)) { std::cout << "matched!" << std::endl; }
}
2 Answers
Related