![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
regex_error in C++
The regex library has different methods and features related to regular expressions. Here we will see some regex_errors. These are also present at regex library. During executing some regular expressions, we get some errors. That errors are mentioned here.
Flags | Errors |
---|---|
error_collate | In the Regex, the names having invalid collation. |
error_ctype | In the Regex, there is an invalid character class name. |
error_stack | Not enough memory to determine regex can be matched or not. |
error_space | Convert into Finite State Machine, when memory is insufficient |
error_badrepeat | The string has repeat specifier ( *?+{) that was not preceded by a valid regular expression. |
error_complexity | The complexity of an attempted match against a regex exceeded a pre-set level |
error_range | Containing invalid character range. |
error_badbrace | The regex contains mismatched braces { and }. |
error_brace | The regex contains invalid range between braces { and }. |
error_paren | The regex contains mismatched parentheses ( and ). |
error_brack | The regex contains mismatched brackets ([ and ]). |
error_backref | The regex excepts invalid back reference. |
error_escape | The regex does not allows any invalid escaped character, or a trailing escape. |
Example
#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"; } } }
Output
There is an error. The error is: Unexpected character in bracket expression. This is the code of error_brack
Advertisements