C ++中的regex_error
regex库具有与正则表达式相关的不同方法和功能。在这里,我们将看到一些regex_errors。这些也存在于正则表达式库中。在执行一些正则表达式期间,我们会遇到一些错误。这些错误在这里提到。
示例
#include <iostream>
#include <regex>
int main() {
try {
std::regex re("[A-Z][0"); //an error is present
} catch (const std::regex_error& err) {
std::cout << "There is an error. The error is: " << err.what() << '\n';
if (err.code() == std::regex_constants::error_brack) {
std::cout << "This is the code of error_brack\n";
}
}
}输出结果
There is an error. The error is: Unexpected character in bracket expression. This is the code of error_brack
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短