procedure TForm1.Button4Click(Sender: TObject);
var a,b:string;
i:integer;
begin
a:='0:aa;1:bbl;2:cc';
b:='';
for i:=1 to length(a) do
begin
if (a[i]=':') or (a[i]=';') then
b:=b+#13#10
else
b:=b+a[i]; end;
showmessage(b);
end;
var a,b:string;
i:integer;
begin
a:='0:aa;1:bbl;2:cc';
b:='';
for i:=1 to length(a) do
begin
if (a[i]=':') or (a[i]=';') then
b:=b+#13#10
else
b:=b+a[i]; end;
showmessage(b);
end;
procedure TForm1.Button4Click(Sender: TObject);
var a,b:string;
i:integer;
begin
a:='0:aa;1:bbl;2:cc';
b:='';
for i:=1 to length(a) do
begin
if (a[i]=':') or (a[i]=';') then
memo1.lines.add(b);//假设你已加了memo1
b:='';
else
b:=b+a[i]; end;
if b<>'' then memo1.lines.add(b);
//showmessage(b);
end;
var
p: integer;
str_Tmp: string;
ss_Re: tstrings;begin
ss_re := tstringlist.Create;
str_tmp := concat(str_Source, str_compart);
try
repeat
begin
p := pos(str_Compart, str_tmp);
while p = 1 do //去掉左边的分隔符
begin
str_tmp := copy(str_tmp, 2, length(str_tmp) - 1);
p := pos(str_Compart, str_tmp);
end; if p < 0 then
if length(str_tmp) > 0 then //无分隔符时
begin
ss_re.add(str_tmp);
fun_getstritem := ss_re;
exit;
end;
ss_re.Add(copy(str_tmp, 1, p - 1));
str_tmp := copy(str_tmp, p + 1, length(str_tmp) - p);
end;
until (length(str_tmp) = 0);
fun_getstritem := ss_re;
except end;
end;