Delphi 取相同字符串 2种方法
2022-12-12 16:25:25 作者:admin
本文整理自网络,侵删。
。
方法1:感谢 QQ1949223 分享代码procedure TForm1.Button1Click(Sender: TObject);var i:integer; s,t:string;begini:=1;t:='';edit1.Text:=edit1.Text+' ';while i<=length(edit1.Text) dobegin if t <> copy(edit1.Text,i,1) then begin memo1.Lines.Add(s); t:=copy(edit1.Text,i,1); s:=t; end else begin s:=s+t; end; i:=i+1;end;end;
方法2:
procedure TForm7.Button1Click(Sender: TObject);
var
s, s1: string;
i: Integer;
a, prea: char;
begin
s := Trim(Edit1.Text);
for i := 0 to Length(s) do
begin
a := s[i];
if prea <> a then
begin
//对比不同
Memo1.Lines.Add(s1);
s1 := '';
end;
s1 := s1 + a;
prea := a;
end;
Memo1.Lines.Add(s1);
end;
相关阅读 >>
Delphi 调用js字符串编码
Delphi 使richedit中的链接可以点击
indy tidtcpclient 的一个用法上要留意的问题,以及 http
Delphi 字幕下载单元subdownload.pas
Delphi 开关显示器操作
Delphi 一行关键代码阻止360云查杀
Delphi 数组类型与数组指针的巧妙利用
Delphi android-api 开发常用函数
Delphi 与 c/c++ 数据类型对照表
Delphi 限制form窗体为固定的大小
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码