title: Find first occurrence of a string from a vector<string>
body: <p>I have a <code>vector&lt;string&gt; vectorStrings</code> with values: <code>ta, bc, ac, st, cer, cda</code>. I want to find the first occurrence of any of the strings in the vector in an input string.</p>
  
  <p>e.g.</p>
  
  <pre><code>InputStr = "this certainly helps";
  </code></pre>
  
  <p>Of the given strings in the vector, I would want a way to say <code>"cer"</code> was the first occurrence at position <code>5</code>.</p>
  
  <hr>
  
  <pre><code>int min = 9999999;
  string first;
  
  for(int i = 0; i &lt; vectorStrings.size(); i++)
  {
      int pos = InputStr.find(vectorStrings[i]);
  
      if(pos == string::npos)
          continue;
  
      if(pos &lt; min)
      {
          min = pos;
          first = vectorStrings[i];
      }
  }
  
  // values of min and first gives which string occurred first
  // and at the position of it in the input string
  </code></pre>
  
  <p>This implementation works, but I would want to know if there exists a more elegant way to do this with boost libraries or std library.</p>
  
  <p>I am working on Windows and using Visual Studio 2010.</p>