Substr.GetSubstring Method

function GetSubstring(const Src: string; const SrcIdx, SrcLen: Integer): Substring; overload;

A view of SrcLen characters of Src from SrcIdx (1-based), copying none: Subrange as a function.

#NameTypeDescription
1Srcstring
2SrcIdxInteger
3SrcLenInteger

Returns: Substring - The view; it is valid while Src lives unchanged.

Remarks:

Src takes every text kind. The range must lie inside Src, else ESubstringRangeError is raised.

Examples

A view of a string's value part.

uses Substr;

procedure Example;
var Text: string;
begin
    Text := 'key=value';
    Assert(GetSubstring(Text, 5, 5) = 'value');
end;