title: Difference between regex_match and regex_search?
body: <p>I was experimenting with regular expression in trying to make an answer to <a href="https://stackoverflow.com/questions/11627440/regex-c-extract-substring">this question</a>, and found that while <code>regex_match</code> finds a match, <code>regex_search</code> does not.</p>
  
  <p>The following program was compiled with g++ 4.7.1:</p>
  
  <pre><code>#include &lt;regex&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      const std::string s = "/home/toto/FILE_mysymbol_EVENT.DAT";
      std::regex rgx(".*FILE_(.+)_EVENT\\.DAT.*");
      std::smatch match;
  
      if (std::regex_match(s.begin(), s.end(), rgx))
          std::cout &lt;&lt; "regex_match: match\n";
      else
          std::cout &lt;&lt; "regex_match: no match\n";
  
      if (std::regex_search(s.begin(), s.end(), match, rgx))
          std::cout &lt;&lt; "regex_search: match\n";
      else
          std::cout &lt;&lt; "regex_search: no match\n";
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre>
  regex_match: match
  regex_search: no match
  </pre>
  
  <p>Is my assumption that both should match wrong, or might there a problem with the library in GCC 4.7.1?</p>