title: Efficient filtering of words in a string of text
body: <p>When people type text into a textfield, before it is added to the textbox (for chat) there are certain words I want to look for and filter. This includes if they are not space spliced example the word space in spaceship.</p>
  
  <p>What sort of algorithm is generally used for this sort of purpose?</p>
  
  <p>The only algorithm I can think of iterates over the text for each word:</p>
  
  <pre><code>for each word to filter
  for each char in string
  if the substring from index of the first letter of word to the current index == word, do something with the word
  end for each
  end for each
  </code></pre>
  
  <p>Is there a better, more O(n) way to do it?</p>
  
  <p>Thanks</p>