一串字符,想逐个提取中括号里的字符
解决方案 »
- 大家伙谈谈用XE3后的感受,!!!!
- 欢迎加入 DELPHI游戏外挂讨论群,号码:26429926
- 信息服务系统整体架构,请给一个方案
- 2个问题:如何获取拷贝文件时的速度,即复制需要的时间!怎么写复制文件时的进度条!
- 在线等待,目录文件问题
- 在IIS下怎么配置WebServices服务,多谢
- 我用超级报表(vc)时在(delphi)中使用Getxxx方法返回都是空.vb没问题.
- 网络计时怎么作?
- 简单的问题 对你们是简单的
- 请问哪里有内容比较详细的d5或d6指南下载???送分了!!!!
- delphi sppcomm串口通信
- TADOConnectiong连接oracle问题,解决可再加分100
uses StrUtils;procedure TForm1.FormCreate(Sender: TObject);
var
I: integer;
S: string;
begin
S := '[1][2][3][4][5]'; with TStringList.Create do
begin
Delimiter := ']';
DelimitedText := AnsiReplaceText(S, '[', '');
for I:=0 to Count-1 do
if Strings[I]<>'' then ShowMessage(Strings[I]);
Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s,str: string;
i,l: integer;
b: boolean;
begin
b:= false;
s:= '日期:[fDate] 单据号:[fNo]';
l:= length(s);
for i:= 1 to l do
begin
if not b then
if s[1] <> '[' then delete(s,1,1) else
begin
b:= true;
delete(s,1,1);
end
else
begin
if s[1] <> ']' then str:= str+s[1] else
begin
b:= false;
Memo1.Lines.Append(str);
str:= '';
end;
delete(s,1,1);
end
end;
showmessage(str);
end;
var
i,j:Integer;
begin
i:=Pos('[',S);
while i>0 do
begin
j:=PosEx(']',S,i);
if (i>0)and(j>0) then
AList.Add(Copy(S,i+1,j-i-1))
else if j<=0 then
break;
i:=PosEx('[',S,j);
end;
Result:=AList.Count;
end;procedure TForm1.btn1Click(Sender: TObject);
var
AList:TStringList;
S:String;
begin
s:= '日期:[fDate] 单据号:[fNo]';
AList:=TStringList.Create;
AnalyzeStr(S,AList);
Showmessage(AList.Text);
AList.Free;
end;