title: Parsing *.cpp file containing enum using boost::regex.
body: <p>I alredy parsed file and split content to enum or enum classes.</p>
  
  <pre><code>std::string sourceString = readFromFile(typesHDestination);
  boost::smatch xResults;
  std::string::const_iterator Start = sourceString.cbegin();
  std::string::const_iterator End = sourceString.cend();
  
  while (boost::regex_search(Start, End, xResults, boost::regex("(?&lt;data_type&gt;enum|enum\\s+class)\\s+(?&lt;enum_name&gt;\\w+)\\s*\{(?&lt;content&gt;[^\}]+?)\\s*\}\\s*")))
  {
      std::cout &lt;&lt; xResults["data_type"]
          &lt;&lt; " " &lt;&lt; xResults["enum_name"] &lt;&lt; "\n{\n";
  
      std::string::const_iterator ContentStart = xResults["content"].begin();
      std::string::const_iterator ContentEnd = xResults["content"].end();
      boost::smatch xResultsInner;
  
      while (boost::regex_search(ContentStart, ContentEnd, xResultsInner, boost::regex("(?&lt;name&gt;\\w+)(?:(?:\\s*=\\s*(?&lt;value&gt;[^\,\\s]+)(?:(?:,)|(?:\\s*)))|(?:(?:\\s*)|(?:,)))")))
      {
          std::cout &lt;&lt; xResultsInner["name"] &lt;&lt; ": " &lt;&lt; xResultsInner["value"] &lt;&lt; std::endl;
  
          ContentStart = xResultsInner[0].second;
      }
  
      Start = xResults[0].second;
      std::cout &lt;&lt; "}\n";
  }
  </code></pre>
  
  <p>Its ok if enums are without comments.
  <a href="https://i.stack.imgur.com/jsYqY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsYqY.png" alt="Output"></a></p>
  
  <p>I tried to add named group <code>&lt;comment&gt;</code> to save comments in enums, but failed every time. <code>(\/{2}\s*.+)</code> - sample for comments with double slashes.</p>
  
  <p>I tested using this <a href="https://regex101.com/" rel="nofollow noreferrer">online regex</a> and with boost::regex.</p>
  
  <ol>
  <li>The first step - from *.cpp file to <code>&lt;data_type&gt; &lt;enum_name&gt; &lt;content&gt;</code>
  regex: </li>
  </ol>
  
  <blockquote>
    <p>(?'data_type'enum|enum\s+class)\s+(?'enum_name'\w+)\s*{\s*(?'content'[^}]+?)\s*}\s*</p>
  </blockquote>
  
  <ol start="2">
  <li>From <code>&lt;content&gt;</code> to <code>&lt;name&gt; &lt;value&gt; &lt;comment&gt;</code>
  regex: </li>
  </ol>
  
  <blockquote>
    <p>(?'name'\w+)(?:(?:\s*=\s*(?'value'[^\,\s/]+)(?:(?:,)|(?:\s*)))|(?:(?:\s*)|(?:,)))</p>
  </blockquote>
  
  <p>The last one contains error. Is there any way to fix it and add feature to store coments in group?</p>