Returns true if a string ends with a substring StrUtils unit
 function AnsiEndsStr(const Needle, Haystack string):Boolean;
The AnsiEndsStr function looks for a Needle string at the end of a Haystack string, returning true if it finds it. Otherwise false.
It is a Case sensitive command.
Related commands
AnsiContainsStrReturns true if a string contains a substring
AnsiStartsStrReturns true if a string starts with a substring
AnsiContainsTextReturns true if a string contains a substring, case insensitive
 Download this web site as a Windows program.

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

  // Note that AnsiEndsStr is case sensitive
  if AnsiEndsStr('the MAT', haystack)
  then ShowMessage('''the MAT'' ends the sentence')
  else ShowMessage('''the MAT'' does not end the sentence');

  if AnsiEndsStr('the mat', haystack)
  then ShowMessage('''the mat'' ends the sentence')
  else ShowMessage('''the mat'' does not end the sentence');
Show full unit code
  'the MAT' does not end the sentence
  'the mat' ends the sentence
Delphi Programming © Neil Moffatt 2002 - 2022. All rights reserved.  |  Home Page