replaceFrom__

replaceFrom__(target:      String;
              replacement: String;
              startIndex:  Integer;
              bIgnoreCase: Boolean): String;

The replaceFrom__ method of the String primitive type replaces only the first occurrence of the substring specified in the target parameter with the substring specified in the replacement parameter, starting from the specified startIndex parameter.

Case‑sensitivity is ignored if you set the value of the bIgnoreCase parameter to true. Set this parameter to false if you want the substring replacement to be case‑sensitive.

This method raises exception 1413 (Index used in string operation is out of bounds) if the value specified in the startIndex parameter is less than 1 or it is greater than the length of the original string. In addition, it returns the original receiver String if the value specified in the target parameter has a length of zero (0); that is, it is an empty string.

The following example shows the use of the replaceFrom__ method.

vars
    output, input : String;
begin
    input := "ababab";
    output := input.replaceFrom__('b','a',6,false);
    write output; // ababaa
end;

2018.0.01 and higher