稍微一改就行了。
procedure TForm1.Button1Click(Sender: TObject);
var
tofind: string;
begin
richedit.SelStart := 0;
if Fedit.text <> '' then
while find(tofind) do
richedit.SelAttributes.Color := clRed; //这里是你对找到的字符串的属性修改
end;
function TForm1.find(tofind: string): boolean;
var
FindIn,findin2: string;
flen,start,holder,found,index: integer;
begin
result := True;
ToFind := lowercase(fedit.text);
findin := lowercase(richedit.text);
flen := length(tofind);
found := 0;
index := -1;
start := richedit.selstart;
if lowercase(richedit.seltext) = lowercase(tofind) then
richedit.perform(em_setsel, start +flen, start +flen);
start := richedit.selstart;
holder := start +1;
while found = 0 do
begin
if holder > (richedit.gettextlen)+223 then
begin
ActiveControl := richedit;
result := false;
exit;
end;
findin2 := concat(' ',copy(findin,holder,250),' ');
found := pos(tofind, findin2);
holder := holder + 225;
index := index +1;
end;
if index > 0 then index := index *225 else index := 0;
holder := start +index +found-3;
ActiveControl := richedit;
richedit.perform(em_setsel, holder, holder +flen);
richedit.perform(em_scrollcaret, 0,0);
end;