title: "std::regex" with C++11
body: <p>I am trying the C++ standard regex library. But it is throwing std::regex_error exception. No idea what is going wrong. I can use Boost regex or PCRE also. </p>
  
  <p>But I thought of going with G++ provided regex module. But unable to make it work with even simple expressions. Don't worry about the unused variables, I started with a moderately complex expression which needed them. But now I have reduced it just to match a word.</p>
  
  <p>Please check sample which is crashing here:</p>
  
  <p><a href="http://ideone.com/fork/58EV7v" rel="nofollow">http://ideone.com/fork/58EV7v</a> </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;regex&gt;
  
  int main()
  {
      const char *vals = "abcdef";
      unsigned long start;
      unsigned int off;
      unsigned int size;
  
      std::cmatch cr;
      std::regex rx("(\\w+)");
      std::regex_match(vals, cr, rx);
      std::cmatch::iterator it = cr.begin();
      while (it != cr.end()){
          std::cout &lt;&lt; *it &lt;&lt; std::endl;
          ++it;
      }
  
      return 0;
  }
  </code></pre>