比如字符串:
aaa;bbb ccc;ddd,ef;kk
用什么方法将其分割到TStringList中,如下:
aaa
bbb ccc
ddd,ef
kk高手请指教,急啊
aaa;bbb ccc;ddd,ef;kk
用什么方法将其分割到TStringList中,如下:
aaa
bbb ccc
ddd,ef
kk高手请指教,急啊
解决方案 »
- Treeview DBGrid问题
- 很简单的数据库写入数据问题!要分的进!
- 网上交易的项目难道都是骗局吗?我该怎么做?
- 高分求源码
- 请问能否在搜索出来的记录中继续搜?
- 程序如何区分数字和字符的(16进制)
- kds(生) (▲▲) 信誉:100 ,具体是什么含义?
- messagebox这个api函数,如果只有一个ok按钮,怎样让对话框的关闭变成灰色?
- 各位:那里可以下载Installshield 东方版, 或其语言包?
- 请Delphi高手指点一个C++ Builder的难题----不知道SpeedButton1->Caption的快捷键能否在窗体创建时动态改变??
- 控件问题!..我的心在线等待..急急!!
- 可以实现这样的功能吗?
sL :TStringList;
str,strtemp :string;
i:integer;
begin
sL :=TStringList.Create;
str :='sfadf;hhg;oaa;sds;dfdgd';
try
for i:=1 to Length(Str) do
begin
if Str[i]=';' then
begin
sL.Add(strtemp);
strtemp :='';
end
else begin
strtemp :=strtemp+str[i];
end;
end;
except end;
end;
const Delimiters: TCharSet = [','] ) : string;
var
l, i, p: integer;
begin
result := '';
if (S = '') then Exit;
l:=Length(S);
i:=1;
p:=0;
while (i<=l) and (p=0) do
begin
if S[i] in Delimiters
then p:=i;
Inc(i);
end;
if (p=0) and (i>l)
then p:=i;
if p>0 then
begin
SetLength(Result, p-1);
Result:= Copy(S, 1, p-1);
S:= Copy (S, p+1, l-p);
end;
end;该函数返回第一个由用户定义的分隔符位置前面的所有内容(不包含分隔符)。
同时删除字符串中相应的部分(包括分隔符)。
var
tem: string;
len: integer;
i: integer;
j: integer;
ss: string;
ResArry: array[1..100] of integer;
begin
tem := '1 2 12 35 45 5 8 15';
ss := '';
len := length(tem);
j := 1;
for i := 0 to len do
begin
if copy(tem, 1, 1) = ';' then
begin
tem := copy(tem, 2, length(tem));
ResArry[j] := strtoint(ss);
j := j + 1;
ss := '';
end
else
begin
ss := ss + (copy(tem, 1, 1));
tem := copy(tem, 2, length(tem));
end; if i = len then
resarry[j] := strtoint(ss);
end;
for i := 1 to j do
showmessage(inttostr(ResArry[i]));
end;我试了可以的,有什么问题发消息给我!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!