std::regex_error
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <regex>
|
||
| class regex_error : public std::runtime_error { public: |
(C++11 起) | |
定义类型的对象时抛出异常来报告错误的正则表达式库.
Original:
Defines the type of object thrown as exceptions to report errors from the regular expressions library.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 成员函数
| 构造一个 regex_error对象 Original: constructs a regex_error object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| std::regex_constants::error_type为一个 regex_error Original: gets the std::regex_constants::error_type for a regex_error The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
Inherited from std::exception
Member functions
| [虚拟的] </ SPAN></div></div>
|
解构异常对象 Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟公有成员函数of std::exception)
|
| [虚拟的] </ SPAN></div></div>
|
返回一个说明字符串 Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (虚拟公有成员函数of std::exception)
|
</div>
[编辑] 为例
#include <regex> #include <iostream> 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"; } }
Output:
regex_error caught: The expression contained mismatched [ and ]. The code was error_brack