title: C++ regex equivalent for string::find
body: <p>I'm trying to edit an open source C++ program to make a simple adjustment so that one of the input's accepts a regexp string instead of a string. I'm a complete C++ noob (never written anything) so I'm hoping someone can point me to a function that will work. Take the following code:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main() {
      std::string str1(&quot;ABCDEABCABD&quot;);
      std::string pattern(&quot;A&quot;);
  
      int count1 = 0;
  
      size_t p1 = str1.find(pattern, 0);
      while(p1 != std::string::npos)
      {
          p1 = str1.find(pattern,p1+pattern.size());
          count1 += 1;
      }
  
      std::cout &lt;&lt; count1 &lt;&lt; std::endl;
  }
  </code></pre>
  <p>I would like 'pattern' to accept a regular expression of several patterns seperated by the pipe sign, eg 'A|D' (which would output 5 in this case).</p>
  <p>From what I gather from <a href="http://www.cplusplus.com/reference/string/string/find/" rel="nofollow noreferrer">this C++ reference page</a>, you cannot supply a regular expression like this to the string::find function. What function can I put here instead?</p>