有一字符串
var person={23:["姓名1","性别1","年龄1"],25:["姓名2 ","性别2 ","年龄2"]};如何用Delphi分析出ID为23/25的姓名、性别、年龄。
var person={23:["姓名1","性别1","年龄1"],25:["姓名2 ","性别2 ","年龄2"]};如何用Delphi分析出ID为23/25的姓名、性别、年龄。
解决方案 »
- Dll返回DataSet数据集合问题!老提示invalid pointer operation
- Java写的WebService如附件所示例
- 一個關於TreeView的問題
- 俺的com+组件导出的安装不能用, 提示 注册com+应用程序出错,怎么办?
- 我刚学编程,学pascal但我感觉好象是在学代数这是怎么回事啊
- chm的问题???在线等候
- 过年了! 大家过年好呀!
- 请问哪儿有农历控件?
- MenuItem的caption属性会自动加入一个&...
- 谁知道哪一个API函数可以检测有多少台机器和我建立连接(或访问)。。好答案我将尽力加分。。。。
- dxLookupTreeView默认显示值问题
- DELPHI XE,E2010 Incompatible types: 'string' and 'Integer'错误
或者用正则表达式咯!
begin
Result := '';
if AStr <> '' then
Result := Copy(AStr, ALen+1, Length(AStr)- ALen *2);
end;procedure GetStr();
var
LIndex :Integer;
LStr1, LStr2 :string;
LStrList :TStrings;
begin
LStrList := TStringList.Create;
LStr1:='{23:["张三","男","20"],25:["王春芬","女","25"]}' ;
LStr1 := GetMiddleStr(LStr1, 1);
LIndex := Pos(']', LStr1);
while LIndex > 0 do
begin
LStr2 := Copy(LStr1, 1, LIndex);
LStr1 := Copy(LStr1, LIndex+2, Length(LStr1) - LIndex -1 );
Form1.Memo1.lines.Add(LStr2);
Form1.Memo1.lines.Add(LStr1);
LIndex := Pos(']', LStr1);
end;
end;思路先分析串,分解为
23:["张三","男","20"]
25:["王春芬","女","25"]接着再分析吧