title: How to match multiple results using std::regex
body: <p>For example, If I have a string like &quot;first second third forth&quot; and I want to match every single word in one operation to output them one by one.</p>
  <p>I just thought that <code>&quot;(\\b\\S*\\b){0,}&quot;</code> would work. But actually it did not.</p>
  <p>What should I do?</p>
  <p>Here's my code:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  int main()
  {
      regex exp(&quot;(\\b\\S*\\b)&quot;);
      smatch res;
      string str = &quot;first second third forth&quot;;
      regex_search(str, res, exp);
      cout &lt;&lt; res[0] &lt;&lt;&quot; &quot;&lt;&lt;res[1]&lt;&lt;&quot; &quot;&lt;&lt;res[2]&lt;&lt;&quot; &quot;&lt;&lt;res[3]&lt;&lt; endl;
  }   
  </code></pre>