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 |
|
|
|
Example code : A simple example |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses StrUtils, // Unit containing the AnsiEndsStr command Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
haystack : AnsiString;
begin
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');
end; end.
|
Hide full unit code |
'the MAT' does not end the sentence
'the mat' ends the sentence
|
|