in Delphi Strings :: Whatever type of applications you are creating using Delphi, you must be writing some code to handle strings. Delphi provides a healthy assortment of string operators, functions and procedures in RTL.
Let's say that you need to determines whether the beginning of a string matches a specified string? Delphi provides at least 4 ways to check if a string starts with another (sub)string.
Here's what functions you can use (note that LeftStr and AnsiStartsStr are defined in the strutils.pas unit):
const text = 'application'; starter = 'ap' begin AnsiStartsStr(starter, text); Pos(starter, text) = 1; LeftStr(text, Length(starter)) = starter; Copy(text, 1, Length(starter)) = starter; end;
Note: All 4 functions provide case-sensitive matching.
The question that you could be asking yourself (at least I did) is: what's the best / fastest way?