Is There a Way to Discard Empty Captures?
<p>Is there a built in way to iterate over non-empty captures only or do I need to use a lambda/modify my regex?</p>

<p>For example, given: <code>const auto input = "Peas&amp;Carrots Spinach-Casserole Beets Pizza Spinach-Salad Coleslaw"s</code> I'd like to find foods that <em>don't</em> contain "Spinach". So I can do this:</p>

<pre><code>const regex re{ "\\s*(?:\\S*Spinach\\S*|(\\S*))" };

copy(sregex_token_iterator(cbegin(input), cend(input), re, 1), sregex_token_iterator(), ostream_iterator&lt;string&gt;(cout, "\n"));
</code></pre>

<p>The problem of course is that <a href="http://ideone.com/Gdt4hC" rel="nofollow">I get an output</a> like:</p>

<blockquote>
  <p>Peas&amp;Carrots<br>
  <br>
  Beets<br>
  Pizza<br>
  <br>
  Coleslaw</p>
</blockquote>

<p>Is there a way around this?</p>