std::regex_error
來自 cppreference.com
在標頭檔案 <regex> 中定義 |
||
class regex_error; |
(C++11 起) | |
定義用於報告正則表示式庫中錯誤的異常物件型別。
繼承圖
目錄 |
[編輯] 成員函式
構造一個 regex_error 物件(公有成員函式) | |
替換 regex_error 物件(公有成員函式) | |
獲取 regex_error 的 std::regex_constants::error_type(公有成員函式) |
繼承自 std::exception
成員函式
[虛擬函式] |
銷燬異常物件 ( std::exception 的虛公有成員函式) |
[虛擬函式] |
返回解釋字串 ( std::exception 的虛公有成員函式) |
[編輯] 示例
執行此程式碼
#include <iostream> #include <regex> int main() { try { std::regex re("[a-b][a"); } catch (const std::regex_error& e) { std::cout << "regex_error caught: " << e.what() << '\n'; if (e.code() == std::regex_constants::error_brack) std::cout << "The code was error_brack\n"; } }
可能的輸出
regex_error caught: The expression contained mismatched [ and ]. The code was error_brack