I have code that goes through a file to find dates but its not returning that it found a match to my regular expression.
CODE:
std::string s(line);
std::smatch m;
std::regex e("^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$");
std::cout << "Target sequence: " << s << std::endl;
std::cout << "Regular expression: ^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$" << std::endl;
std::cout << "The following matches and submatches were found:" << std::endl;
while (std::regex_search(s, m, e)) {
for (auto x : m) std::cout << x << " ";
std::cout << std::endl;
s = m.suffix().str();
}
OUTPUT:
Success
Target sequence: 12/28/2002 2 15 38 43 50
Regular expression: ^[0,1]?d{1}/(([0-2]?d{1})|([3][0,1]{1}))/(([1]{1}[9]{1}[9]{1
}d{1})|([2-9]{1}d{3}))$
The following matches and submatches were found:
Enter q to quit:
Is my regular expression not correct or is it something else?