try this sample:
function MyFindAndReplace2(const AStr: string; const ASubStr: string; const ADelimiter: Char): string;
var
LArr : TArray<string>;
LNewArr: TArray<string>;
begin
result := AStr.Replace(' ', '', [rfReplaceAll]); // removing blank-spaces...
//
if (result.Trim = '') or (ASubStr.Trim = '') or (ADelimiter = #32) then
exit('');
//
LArr := result.Split([ADelimiter], TStringSplitOptions.ExcludeEmpty);
//
for var i: integer := 0 to high(LArr) do // only if not found!
if (LArr[i] <> ASubStr) then
LNewArr := LNewArr + [LArr[i]];
//
result := ''.join(ADelimiter, LNewArr);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
LText : string;
LSubText: string;
begin
LText := ' 100,1000, 10, 1001, 101,102,100,,,,103,104, 100,100'; // ' '; // ' ,,'; // ' 1, ,';
LSubText := '100';
//
Memo1.Text := LText;
//
Memo1.Lines.Add('Result=[' + MyFindAndReplace2(LText, LSubText, ',') + ']');
end;