title: C#: Efficiently search a large string for occurences of other strings
body: <p>I'm using C# to continuously search for multiple string "keywords" within large strings, which are >= 4kb. This code is constantly looping, and sleeps aren't cutting down CPU usage enough while maintaining a reasonable speed. The bog-down is the keyword matching method.</p>
  
  <p>I've found a few possibilities, and all of them give similar efficiency.</p>
  
  <p>1) <a href="http://tomasp.net/articles/ahocorasick.aspx" rel="noreferrer">http://tomasp.net/articles/ahocorasick.aspx</a>
  -I do not have enough keywords for this to be the most efficient algorithm.</p>
  
  <p>2) Regex. Using an instance level, compiled regex.
  -Provides more functionality than I require, and not quite enough efficiency.</p>
  
  <p>3) String.IndexOf.
  -I would need to do a "smart" version of this for it provide enough efficiency. Looping through each keyword and calling IndexOf doesn't cut it.</p>
  
  <p>Does anyone know of any algorithms or methods that I can use to attain my goal?</p>