Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

regex_error::regex_error

Constructs the object.

regex_error(regex_constants::error_code error);
error

The error code.

The constructor constructs an object that holds the value error.

 

// std_tr1__regex__regex_error_construct.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    std::regex_error paren(std::regex_constants::error_paren); 
 
    try 
        { 
        std::regex rx("(a"); 
        } 
    catch (const std::regex_error& rerr) 
        { 
        std::cout << "regex error: " 
            << (rerr.code() == paren.code() 
                ? "unbalanced parentheses" : "?") 
            << std::endl; 
        } 
    catch (...) 
        { 
        std::cout << "unknown exception" << std::endl; 
        } 
 
    return (0); 
    } 
 
regex error: unbalanced parentheses

Header: <regex>

Namespace: std

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.