比如:
字符串"abc+efg+h"
按字符"+"分割到数组a中,
a[0]='abc'
a[1]='efg'
a[2]='h';
如何实现?
字符串"abc+efg+h"
按字符"+"分割到数组a中,
a[0]='abc'
a[1]='efg'
a[2]='h';
如何实现?
解决方案 »
- please verify that the miscrosoft data access components 2.1(or later) have been properly installed.
- 请帮忙,用原生ado重写delphi代码
- 游戏例程
- 分享[windows消息大全]文档中心的
- delphi窗体中更改控件的问题
- 指针取值的问题
- 请问谁有Install Shield中文资料!急用!!
- 如何不返回消息?
- 求高手改一个IM系统
- WINDOWS2000的渐显菜单如何在DELPHI中实现?知道的进来-———
- 请教DELPHI高手,如何让程序在非XP系统中使用XP的风格界面?
- 请问:外挂软件问题,对已经买回来的软件做一些修改
var
i,iCnt:integer;
a:Array of string;
strTemp:string;
begin
strTemp:=Edit1.Text;
iCnt:=1;
SetLength(a,iCnt);
while Pos('+',strTemp)>0 do
begin
SetLength(a,iCnt+1);
a[iCnt-1]:=Copy(strTemp,1,Pos('+',strTemp)-1);
strTemp:=Copy(strTemp,Pos('+',strTemp)+1,Length(strTemp));
inc(iCnt);
end;
a[iCnt-1]:=strTemp;
for i:=0 to iCnt-1 do
Memo1.Lines.Add(a[i]);
end;
CommaText
DelimitedText
Delimiter
procedure TForm1.Button1Click(Sender: TObject);
var
ar: array of string;
sl: TStringList;
s: string;
I: integer;
begin
s := Edit1.Text;
sl := TStringList.Create;
sl.Delimiter := '+';
sl.DelimitedText := s; SetLength(ar, sl.Count); for i := 0 to sl.Count - 1 do
ar[i] := sl.Strings[i];
Memo1.Lines := sl;
end;