Returns true if a string contains a substring StrUtils unit
 function AnsiContainsStr ( const Haystack, Needle : string ) : Boolean;
The AnsiContainsStr function looks for a Needle string in a Haystack string, returning true if it finds it. Otherwise false.
It is a Case sensitive command.
Related commands
AnsiEndsStr Returns true if a string ends with a substring
AnsiStartsStr Returns true if a string starts with a substring
AnsiContainsText Returns true if a string contains a substring, case insensitive
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : A simple example
  haystack : AnsiString;
  haystack := 'The cat sat on the mat';

  // Note that AnsiContainsStr is case sensitive
  if AnsiContainsStr(haystack, 'THE')
  then ShowMessage('''THE'' was found')
  else ShowMessage('''THE'' was not found');

  if AnsiContainsStr(haystack, 'the')
  then ShowMessage('''the'' was found')
  else ShowMessage('''the'' was not found');
Show full unit code
   'THE' was not found
   'the' was found
Delphi Programming Neil Moffatt 2002 - 2018. All rights reserved.  |  Home Page