| 33 | using boost::algorithm::starts_with; |
| 34 | |
| 35 | int num_from_string(const std::string& query_str) { |
| 36 | if (query_str.empty()) { |
| 37 | return 0; |
| 38 | } |
| 39 | const char* pattern = "\\d+"; |
| 40 | boost::regex re(pattern); |
| 41 | boost::match_results<std::string::const_iterator> what; |
| 42 | auto start = query_str.begin(); |
| 43 | auto end = query_str.end(); |
| 44 | int found_num = 0; |
| 45 | while (boost::regex_search(start, end, what, re)) { |
| 46 | start = what[0].second; |
| 47 | found_num = std::stoi(what[0].str()); |
| 48 | } |
| 49 | return found_num; |
| 50 | } |
| 51 | |
| 52 | bool numeric_string_compare(const std::string& s1, const std::string& s2) { |
| 53 | return num_from_string(s1) < num_from_string(s2); |
no test coverage detected