Trimming all instances of a string from a string
   


This function is the same as TrimAllChar(), but removes all instances of a string from a string. Read the comment for the usage. Thanks to Jay <[email protected]> for this code.

function TrimAllStr(const S: stringconst Target : string): string;
{ func to remove instances of a string (Target) from a string (S). }
{ e.g. TrimAllStr('ABthis ABis ABa ABtest', 'AB') will return 'this is a test'. }
{ Thanks to Jay <[email protected]> for this code. }

var
  P: integer;
begin
  Result := S;
  repeat
    P := Pos(Target, Result);
    if P > 0 then
      System.Delete(Result, P, Length(Target)); 
  until
    (P = 0);
end;



Blue Orb Software

[email protected]