ObjectPascal
AnsiEndsStr
Function
Returns true if a string ends with a substring StrUtils unit
 function AnsiEndsStr ( const Needle, Haystack : string ) : Boolean;
Description
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
AnsiContainsStr Returns true if a string contains a substring
AnsiStartsStr Returns true if a string starts with a substring
AnsiContainsText Returns true if a string contains a substring, case insensitive
 
Example code : A simple example
var
  haystack : AnsiString;
begin
  haystack := 'The cat sat on the mat';

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

  if AnsiEndsStr('the mat', haystack)
  then WriteLn('''the mat'' ends the sentence')
  else WriteLn('''the mat'' does not end the sentence');
end;
Show full unit code
   'the MAT' does not end the sentence
   'the mat' ends the sentence