title: Comparing a String to a List of Words
body: <p>I'm trying to implement a search function in a program I am writing. At the moment, I have a list of strings which I am searching through.</p>
  
  <p>What I'd like to do is check whether <em>all</em> words that have been typed into a search box appear in the search results. However, the catch is that they can appear in any order. So for example, if the string is:</p>
  
  <blockquote>
    <p>The quick brown fox jumps over the lazy dog</p>
  </blockquote>
  
  <p>and I were to type:</p>
  
  <blockquote>
    <p>dog fox brown</p>
  </blockquote>
  
  <p>It would return a positive match.</p>
  
  <p>My first thought was to <code>.split</code> the words in the search box into an array. Then, iterate through the list of strings, and check to see if the string contained every word in the array, else, remove it from the list. Once all the strings have been iterated through, display the results.</p>
  
  <p>However, I can imagine that there would be a significant amount of overhead, especially because I'd like the filtering to be done real-time, ie. attached to the TextChanged event of the textbox.</p>
  
  <p>Is there a more efficient way of doing this filtering? I just wanted to make sure that there wasn't a more efficient way of doing this before I started coding it.</p>