Topic: How To Use Function Replace + Option

How To Replace Text In '['+Alltext+']'
Example Original text

[Lorem Ipsum] is [simply dummy] text of the printing [and] typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

For Result

XXX is XXX text of the printing XXX typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

How To use function Or Edit code ???

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Use Function Replace + Option

Hello.


I made function ReplaceStrEx for that:


function ReplaceStrEx(AText, FromText, ToText: string): string;
var
    ArStr: array of string;
    i, c: integer;
begin
    ArStr := SplitString(FromText, ',');
    c := Length(ArStr)-1;
    for i := 0 to c do
    begin
        AText := ReplaceStr(AText, ArStr[i], ToText);
    end;
    result := AText;
end;

// how to use
procedure Form1_Button4_OnClick (Sender: TObject; var Cancel: boolean);
begin
    Form1.Memo2.Text := ReplaceStrEx(Form1.Memo1.Text, 'Lorem Ipsum,simply dummy,and', 'XXX');
end;
Dmitry.