replacetext函数吧,查一下帮助,很简单
解决方案 »
- 请问初学delphi用D7好还是XE2好?听讲XE2已经不是用object pascal了!.
- 初学indy,udp发送信息问题
- 有一定挑战性的问题:dbGridEh中,有一字段为checkbox类型的,点击某一行的checkbox,触发的是啥事件?
- 如何在运行期间动态改变TToolbar中TToolButton的位置
- Help me!
- Delphi中TMethod的用法
- socket的使用
- 简单问题送分!怎样使xp可以用java(在线等,马上结账)
- insert
- 请问最简单的局域网短信息传送方法?要求使用最简单
- 招聘!!!!
- 怎样正确使用clientscoket\serversocket控件?
并replace.D5下调试成功。procedure Tmainfm.Button1Click(Sender: TObject);
var SelPos: Integer;
s : string;//查找的字符串
ss;//替代的string
begin
with TReplaceDialog(Sender) do
begin
s := #$D#$A;
ss := ' ';
SelPos := Pos(s, Memo1.Lines.Text);
if SelPos > 0 then
begin
Memo1.SelStart := SelPos - 1;
Memo1.SelLength := Length(s);
Memo1.SelText := ss;
end
else showmessage('No found!');
end;
end;
SourceStr:string;
Post:Integer;
begin
SourceStr:='this is test '+#13#10+'next line';
Post:=Pos(#$D#$A,SourceStr);
while Post>0 do
begin
Delete(sourceStr,Post,2);
Insert(' ',SourceStr,Post);
Post:=Pos(#$D#$A,SourceStr);
end;
end;
var
I: Integer;
Source: string;
begin
Source := S;
Result := '';
repeat
I := Pos(Srch, Source);
if I > 0 then begin
Result := Result + Copy(Source, 1, I - 1) + Replace;
Source := Copy(Source, I + Length(Srch), MaxInt);
end
else Result := Result + Source;
until I <= 0;
end;