| 112 | } |
| 113 | |
| 114 | std::string OHDUtil::string_in_between(const std::string& start, |
| 115 | const std::string& end, |
| 116 | const std::string& value, bool debug) { |
| 117 | const std::regex base_regex(start + "(.*)" + end); |
| 118 | std::smatch base_match; |
| 119 | std::string matched; |
| 120 | if (std::regex_search(value, base_match, base_regex)) { |
| 121 | // The first sub_match is the whole string; the next |
| 122 | // sub_match is the first parenthesized expression. |
| 123 | if (base_match.size() == 2) { |
| 124 | matched = base_match[1].str(); |
| 125 | } |
| 126 | } |
| 127 | if (debug) { |
| 128 | openhd::log::get_default()->debug("Given:[{}] Result:[{}]", value, matched); |
| 129 | } |
| 130 | return matched; |
| 131 | } |
| 132 | std::optional<int> OHDUtil::string_to_int(const std::string& s) { |
| 133 | try { |
| 134 | auto ret = std::stoi(s); |