// *** before: ***
uses
SysUtils, StrUtils;
var
S: string;
begin
S := ' Hello, world ';
S := Trim(S);
if AnsiStartsText('Hello', S) then
Writeln(UpperCase(S));
Writeln(Pos('world', S));
Writeln(StringReplace(S, 'world', 'Delphi', [rfReplaceAll]));
end;
// *** in version XE3: ***
uses
System.SysUtils;
var
S: string;
Part: string;
begin
S := ' Hello, world ';
S := S.Trim;
if S.StartsWith('Hello') then
Writeln(S.ToUpper);
Writeln(S.IndexOf('world')); // counted from zero
Writeln(S.Replace('world', 'Delphi'));
Writeln(S.Contains(','), ' ', S.IsEmpty, ' ', S.Length);
for Part in S.Split([',']) do
Writeln(Part.Trim);
end;
// careful: TStringHelper counts positions from zero, while S[1] and Pos
// still count from one