std::regex_error - cppreference.com
来自cppreference.com
| (C++11 起) | ||
定义抛出的异常对象类型,以报告正则表达式库中的错误。
继承图
成员函数
示例
#include <iostream> #include <regex> int main() { try { std::regex re("[a-b][a"); } catch (const std::regex_error& e) { std::cout << "捕获 regex_error: " << e.what() << '\n'; if (e.code() == std::regex_constants::error_brack) std::cout << "错误码为 error_brack\n"; } }
可能的输出:
捕获 regex_error: The expression contained mismatched [ and ]. 错误码为 error_brack