| 13 | namespace util { |
| 14 | |
| 15 | std::string regex(std::string str, std::string regexStr, unsigned group) { |
| 16 | try { |
| 17 | std::regex re(regexStr); |
| 18 | std::smatch match; |
| 19 | if (std::regex_match(str, match, re)) { |
| 20 | assert(group < match.size() && "Out of regex group size!"); |
| 21 | return match[group].str(); |
| 22 | } else { |
| 23 | return ""; |
| 24 | } |
| 25 | } catch (std::regex_error &e) { |
| 26 | std::cout << "regex Exception : " << e.code() << std::endl; |
| 27 | assert("Can't use regex class"); |
| 28 | } |
| 29 | return ""; |
| 30 | } |
| 31 | |
| 32 | std::string demangle(const char *name) { |
| 33 | int status = -1; |