title: Why does this C++11 std::regex example throw a regex_error exception?
body: <p>Trying to learn how to use the new std::regex in C++11.  But the example I tried is throwing a regex_error exception I don't understand.  Here is my sample code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;regex&gt;
  
  int main()
  {
      std::string str = "xyzabc1xyzabc2xyzabc3abc4xyz";
      std::regex re( "(abc[1234])" ); // &lt;-- this line throws a C++ exception
  
      // also tried to do this:
      // std::regex re( "(abc[1234])", std::regex::optimize | std::regex::extended );
  
      while ( true )
      {
          std::cout &lt;&lt; "searching in " &lt;&lt; str &lt;&lt; std::endl;
          std::smatch match;
          std::regex_search( str, match, re );
          if ( match.empty() )
          {
              std::cout &lt;&lt; "...no more matches" &lt;&lt; std::endl;
              break;
          }
          for ( auto x : match )
          {
              std::cout &lt;&lt; "found: " &lt;&lt; x &lt;&lt; std::endl;
          }
          str = match.suffix().str();
      }
      return 0;
  }
  </code></pre>
  
  <p>I compile and run like this:</p>
  
  <pre><code>g++ -g -std=c++11 test.cpp
  ./a.out
  terminate called after throwing an instance of 'std::regex_error'
    what():  regex_error
  </code></pre>
  
  <p>Looking at the backtrace in gdb, I see the exception thrown is <code>regex_constants::error_brack</code>.</p>