pos

pos(substr: String;
    start:  Integer): Integer;

The pos method of the String primitive type returns an integer containing the position of a substring in a string. The substring is specified by the substr parameter. The search for the substring begins at the position specified by the start parameter.

The start parameter must be greater than zero (0) and less than or equal to the length of the receiver. If the substr or the start parameter is greater than the length of the receiver, this method returns zero (0). This method returns zero (0) if the specified substring is not found.

The character search is case-sensitive.

The following example shows the use of the pos method.

vars
    stringValue : String;
begin
    stringValue := 'position example';
    write stringValue.pos('pos', 1);    // Outputs 1
    write stringValue.pos('pos', 10);   // Outputs 0
end;