title: C++ regex string capture
body: <p>Tring to get C++ regex string capture to work.  I have tried all four combinations of Windows vs. Linux, Boost vs. native C++ 0x11.  The sample code is:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;boost/regex.hpp&gt;
  //#include &lt;regex&gt;
  
  using namespace std;
  using namespace boost;
  
  int main(int argc, char** argv)
  {
      smatch sm1;
      regex_search(string("abhelloworld.jpg"), sm1, regex("(.*)jpg"));
      cout &lt;&lt; sm1[1] &lt;&lt; endl;
      smatch sm2;
      regex_search(string("hell.g"), sm2, regex("(.*)g"));
      cout &lt;&lt; sm2[1] &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The closest that works is g++ (4.7) with Boost (1.51.0).  There, the first cout outputs the expected <code>abhelloworld.</code> but nothing from the second cout.</p>
  
  <p>g++ 4.7 with -std=gnu++11 and <code>&lt;regex&gt;</code> instead of <code>&lt;boost/regex.hpp&gt;</code> produces no output.</p>
  
  <p>Visual Studio 2012 using native <code>&lt;regex&gt;</code> yields an exception regarding incompatible string iterators.</p>
  
  <p>Visual Studio 2008 with Boost 1.51.0 and <code>&lt;boost/regex.hpp&gt;</code> yields an exception regarding "Standard C++ Libraries Invalid argument".</p>
  
  <p>Are these bugs in C++ regex, or am I doing something wrong?</p>