title: vc++ std::regex_match returning an extra empty string with an alternation regex
body: <p>Why does this regex return an extra match of an empty string with std::regex_match?</p>
  
  <pre><code>std::regex trim_comments_spaces("^\\s*(?:(?:(.*?)\\s*[/]{2,}.*)|(?:(.*?)\\s*))$");
  </code></pre>
  
  <p>It seems to give the right matches, but I have to access the third element of the std::smatch results.<s>, which makes me suspicious that I got the alteration/grouping/capturing syntax slightly wrong.</s></p>
  
  <pre><code>std::string trim_line(std::string current_line) {
  
      std::string trimmed_line = "";
  
      if (current_line != "#include &lt;glsl.h&gt;") {
  
          std::regex trim_comments_spaces("^\\s*(?:(?:(.*?)\\s*[/]{2,}.*)|(?:(.*?)\\s*))$");
          std::smatch sub_matches;
  
          if (std::regex_match(current_line, sub_matches, trim_comments_spaces)) {
              std::cout &lt;&lt; sub_matches.size() &lt;&lt; "\n";
              std::string sub_string = sub_matches[2].str();
  
              if (sub_string != "") {
                  std::regex validate_line("^(?:(?:[a-z][a-zA-Z0-9\\s_+*\\-/=&gt;&lt;&amp;|^?:{().,[\\]]*[;{})])|[}])$");
  
                  if (std::regex_match(sub_string.begin(), sub_string.end(), validate_line)) {
                      trimmed_line = sub_string;
                  }
                  else {
                      std::cout &lt;&lt; "Syntax error(2): " &lt;&lt; sub_string &lt;&lt; "\n";
                  }           
              }
          }
          else {
              std::cout &lt;&lt; "Syntax error(1): " &lt;&lt; current_line &lt;&lt; "\n";
          }
      }
  
      return trimmed_line;
  }
  </code></pre>