I have the following code:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
const std::string input_data("2014-02-20 12:32:15");
const boost::regex reg_exp("[-:\\d\\s]+");
boost::smatch results;
std::cout << boost::regex_match(input_data, results, reg_exp) << '\n';
}
Output
1
If I change a regular expressions from
"[-:\\d\\s]+"
to
"[\\d:-\\s]+"
this code will output "0", while http://www.regexr.com/ tells that everything is fine. Does boost think that ":-\s" is a range of characters? Is it defined in the regular expression's standard? Who's right?