title: Regex matching groups boost c++
body: <p>[Noob Corner]</p>
  
  <p>Hello,
  I'm trying to catch a group with boost regex depending on the string that matched and I think I'm using a wrong way.</p>
  
  <pre><code>boost::regex expr(R"(:?(:?\busername *(\S*))|(:?\bserver *(\S*))|(:?\bpassword *(\S*)))");
  std::vector&lt;std::string &gt; vec = { "server my.server.eu", "username myusername", "password mypassword" };
  
  for (auto &amp;elem : vec)
  {
     if (boost::regex_match(elem, expr, boost::match_extra))
      {
           boost::smatch what;
           boost::regex_search(elem, what, expr);
  
           std::cout &lt;&lt; "Match 1 (username) : " &lt;&lt; what[1].str() &lt;&lt; std::endl;
           std::cout &lt;&lt; "Match 2 (server) : " &lt;&lt; what[2].str() &lt;&lt; std::endl;
           std::cout &lt;&lt; "Match 3 (password) : " &lt;&lt; what[3].str() &lt;&lt; std::endl;
       }
  }
  </code></pre>
  
  <p>I want something like :</p>
  
  <pre><code>server my.server.eu
  </code></pre>
  
  <blockquote>
    <p>Match 1 (username) : NULL<br/>
    Match 2 (server) : my.server.eu<br/>
    Match 3 (password) : NULL<br/></p>
  </blockquote>
  
  <p>I searched on internet but I have not found clear answers regarding the identification of capturing groups.</p>
  
  <p>Thanks</p>