title: Delphi stringlist finding negative keyword in list
body: <p>I have two string lists that I'm working with.  One that has a list of keywords, and then another that has a list of negative keywords.  I want to be able to search through the list and pick out the list items that do not contain the negative keyword and output to a third keyword list.  I was using the AnsiPos function but that found the negative keywords if they were part of a word, vs full word.</p>
  
  <p>Any suggestions on a relatively easy way to do this?  Speed is not that important, but would be nice.</p>
  
  <p><strong>Example of what I'm looking to do:</strong></p>
  
  <p>Keyword List: </p>
  
  <pre>
  Cat 
  Catfish
  Fish Sticks
  Dog Food
  </pre>    
  
  <p>Negative Keyword List:</p>
  
  <pre>
  Fish
  </pre>
  
  <p>Returned Values Wanted:</p>
  
  <pre>
  Cat 
  Catfish
  Dog Food
  </pre>
  
  <p>This is what I've got so far..  which does not work. I used information from: <a href="https://stackoverflow.com/questions/1678572/is-there-an-efficient-whole-word-search-function-in-delphi">Is There An Efficient Whole Word Search Function in Delphi?</a></p>
  
  <pre><code>function ExistWordInString(aString: PAnsichar; aSearchString: string;
    aSearchOptions: TStringSearchOptions): Boolean;
  var
    Size : Integer;
  begin
    Size := StrLen(aString);
    result := SearchBuf(aString, Size, 0, 0, aSearchString, aSearchOptions) &lt;&gt; nil;
  end;
  
  procedure TForm2.Button1Click(Sender: TObject);
  var
    i, j, index: integer;
    s: string;
    stl: tstringlist;
  begin
    stl := TStringList.Create;
    stl.Text := listbox1.Items.Text;
    for I := 0 to stl.Count - 1 do
    begin
      for j := 0 to listbox2.Count - 1 do
      begin
        if not ExistWordInString(PAnsiChar(listbox2.Items.Strings[j]),
          listbox1.Items.Strings[i], [soWholeWord, soDown])
        then
          listbox3.Items.Append(stl.Strings[i]);
      end;
    end;
  end;
  </code></pre>