Deleting a substring from a specified string.

 

Syntax

procedure Delete(var sSt: string; iFrom, iCount: integer);

 

Parameters

Parameter

Type

Value

sSt

string

source string;

iFrom

integer

index, from which you need to delete the text, must be >0;

iCount

integer

the number of symbols that you need to delete (starting from the specified position).

 

Function result

Deletes the substring from the string based on condition.

 

Example


const
  sOriginal = 'Forever trusting who we are and nothing else matters';
var
  s: string;
  x: integer;
begin
  mLogScript('Original string: "' + sOriginal + '"', '');
  
  s := sOriginal;
  x := pos('nothing else matters', s);
  
    if x > 0 then delete(s, 1, x - 1);
  
  mLogScript('Modified string: "' + s + '"', '');
end.


Script work result

[14:41:39] (Log "Delete"): Original string: "Forever trusting who we are and nothing else matters"

[14:41:39] (Log "Delete"): Modified string: "nothing else matters"
 

See also

mLogScript

Pos

Created with the Personal Edition of HelpNDoc: Easily create EPub books