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 教师闺蜜祝福语简短