Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boost::regex xRegEx1("\"([0-2][0-9])([0-5][0-9])\\s([AP]M)\"");
- boost::smatch xResults;
- if (boost::regex_match(time, xResults, xRegEx1)) {
- cout<<"xResults[0] is "<<xResults[0]<<"\n";
- cout<<"xResults[1] is "<<xResults[1]<<"\n";
- cout<<"xResults[2] is "<<xResults[2]<<"\n";
- cout<<"xResults[3] is "<<xResults[3]<<"\n";
- hours = strtol(xResults[1].str().c_str(), NULL, 10);
- minutes = strtol(xResults[2].str().c_str(), NULL, 10);
- if (strcmp(xResults[3].str().c_str(), "PM")==0) hours = hours + 12;
- return true;
- } else {
- cout<<"Incorrect time format\n";
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement