Substring.Pos Method

Overload List

#SignatureDescription
1function Pos(const SubStr: Substring; const OneOffset: Integer = 1): Integer; overload;
2function Pos(const SubStr: string; const OneOffset: Integer = 1): Integer; overload;The 1-based position of SubStr's first occurrence at or after OneOffset, 0 if none.

Overload 1: function Pos(const SubStr: Substring; const OneOffset: Integer = 1): Integer; overload;

#NameTypeDescription
1SubStrSubstring
2OneOffsetInteger

Returns: Integer

Overload 2: function Pos(const SubStr: string; const OneOffset: Integer = 1): Integer; overload;

The 1-based position of SubStr's first occurrence at or after OneOffset, 0 if none.

#NameDescription
1SubStr

The text searched for, every text kind; an empty one is never found.

2OneOffset

The first position searched, 1-based; below 1 the result is 0.

Returns: Integer - The position in the window, 1-based, or 0.

Examples

Positions in a text.

uses Substr;

procedure Example;
var s: Substring;
begin
    s := Substring('hello');
    Assert(s.Pos('l') = 3);
    Assert(s.Pos('l', 4) = 4);
    Assert(s.Pos('z') = 0);
end;
See Also: Substring.IndexOf, Substring.IndexOf, Substring.IndexOf, Substring.IndexOf, Substring.IndexOf