title: C++ Regular expression on multiple buffers
body: <p>I have a sort of problem with regex, I want it to count multiple (well, in this case, one) buffer as one string.</p>
  
  <p>Let's say I download a file and I want to search for a specific string, let's say "foobar".
  I don't know what the file size will be and I don't want to allocate a huge chunk of couple megabytes of buffer for html code.</p>
  
  <p>So, the idea is, I have this small buffer, lets say 64 bytes.
  Let's say we write a chunk of that file and the char array looks like this</p>
  
  <pre><code>.............foobar.............
  </code></pre>
  
  <p>Everything seems fine, but if the array was like this</p>
  
  <pre><code>.............................foo
  </code></pre>
  
  <p>And on the other write of chunk it becomes</p>
  
  <pre><code>bar.............................
  </code></pre>
  
  <p>The problem is self explanatory. Regex will not find the strings on separate checks. We could allocate big buffer size to contain page at once, but that's a huge waste.</p>
  
  <p>So, I have an idea - split buffers. Let's say on first write we get these buffers</p>
  
  <pre><code> ............................foo
   ------------------------------- // this one is empty
  </code></pre>
  
  <p>then, after second write we get this</p>
  
  <pre><code> ............................foo
   bar............................
  </code></pre>
  
  <p>now, if there was a regex function that would count these buffers as one that would be great. I could simply keep alternating the buffers and pull the strings I want to without allocating a lot of space in ram.</p>
  
  <p>Is there a c++ regex library that would do that? Any ideas?</p>