title: Boost::regex issue, Matching an HTML span element
body: <p>I don't get it. I created this regular expression:</p>
  
  <pre>
  &lt;span class="copy[Green|Red].*>[\s]*(.*)[&#92;s]*&lt;\/span>
  </pre>
  
  <p>to match certain parts of HTML code (a part between spans). For instance the following:</p>
  
  <pre>
  &lt;span class="copyGreen">0.12&lt;/span>
  &lt;span class="copyRed">  0.12  &lt;/span>
  </pre>
  
  <p>Now, this works beautifully with RegexBuddy and others, but with Boost::regex
  I have an issue. It doesn't match up.</p>
  
  <p>EDIT: To be more precise, I want to capture the number between the spans. Before and after
  the number, there can be white spaces as well (&#92;n, &#92;r, etc.).</p>
  
  <p>Here's the code I've been done:</p>
  
  <pre><code>
  try {
          const boost::regex e("&lt;span class=\"copy[Green|Red].*>[\\s]*(.*)[\\s]*&lt;\\/span>");
          boost::smatch matches;
          std::string html("&lt;span class=&#92;"copyGreen&#92;">  0.12  &lt;/span>");
  
          if (boost::regex_match(html, matches, e)) {
                  // Works... (not).
          } else {
                  throw std::runtime_error("Couldn't match the regex against HTML-source!");
          }
  } catch (boost::regex_error& e) {
          std::cout &lt;&lt; e.what() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>What am I doing wrong here? Thanks in advance!</p>
  
  <p>EDIT:</p>
  
  <p>It seems, that the correct expression would be</p>
  
  <pre>boost::regex("&lt;span class=&#92;"copy(?:Green|Red)[^>]*>\\s*(.*?)\\s*&lt;\\/span>"); // Thanks chaos!.</pre>
  
  <p>This actually matches up with Boost. However, I needed to enable boost::match_extra
  in order to get all the captures I needed. This was done by defining</p>
  
  <pre>BOOST_REGEX_MATCH_EXTRA</pre>
  
  <p>in boost\regex\user.hpp</p>
  
  <p>Thank you once again.</p>