Reputation: 23
I'm trying to find a way to read a TEdit input then count how many times the inputted word is used in a paragraph. Basically how this application works is you add a piece of text to the 1st text box, then type in the word you want to select in the 2nd text box, then type the new word in the 3rd text box and finally the original text will be added to the last text box with the replaced words. I need to get a count of how many words have been replaced underneath the final text box. Would really appreciate some advice!
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.
Upvotes: 0
Views: 354