免费 pascal 读取 TEdit 输入

Free pascal read TEdit input

我正在尝试找到一种方法来读取 TEdit 输入,然后计算输入的单词在段落中使用了多少次。这个应用程序的工作原理基本上是你在第一个文本框中添加一段文本,然后在第二个文本框中输入你想要 select 的单词,然后在第三个文本框中输入新单词,最后原始文本将添加到带有替换词的最后一个文本框中。我需要计算最终文本框下方已替换了多少个单词。真的很感激一些建议!

unit Unit1;
{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

{ TForm1 }

TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
edit4.Text:=Stringreplace(Edit1.Text, Edit2.Text, Edit3.Text,
[rfReplaceAll, rfIgnoreCase]);
edit3.Text:=
Label5.Caption:=(c);
end;
end.

您可以获得要替换的字数 like this,然后在用户界面中考虑它应该非常简单。