unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 =
class(TForm)
Original: TMemo;
Neu: TMemo;
Suchen: TEdit;
Ersetzen: TEdit;
Start: TButton;
Start2: TButton;
procedure StartClick(Sender: TObject);
procedure Start2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
//Suchen & Ersetzen - Line-By-Line
procedure TForm2.StartClick(Sender: TObject);
var
CopyText: TStringList;
i: Integer;
begin
CopyText:=TStringList.Create;
try
CopyText.Text:=Original.Text;
for i:=0
to CopyText.Count-1
do
if Pos(Suchen.Text,CopyText.Strings[i])>0
then
CopyText.Strings[i]:=StringReplace(CopyText.Strings[i], Suchen.Text, Ersetzen.Text,[rfReplaceAll, rfIgnoreCase]);
Neu.Text:=CopyText.Text;
finally
CopyText.Free;
end;
end;
//Suchen & Ersetzen - Gesamt Text
procedure TForm2.Start2Click(Sender: TObject);
var
CopyText: TStringList;
begin
CopyText:=TStringList.Create;
try
CopyText.Text:=Original.Text;
CopyText.Text:=StringReplace(CopyText.Text, Suchen.Text, Ersetzen.Text,[rfReplaceAll, rfIgnoreCase]);
Neu.Text:=CopyText.Text;
finally
CopyText.Free;
end;
end;
end.