针对WEB网页里的源代码数据操作的问题(45)

  • 主题发起人 主题发起人 tungh
  • 开始时间 开始时间
T

tungh

Unregistered / Unconfirmed
GUEST, unregistred user!
var dropItem_num=4;var dropItem_data=[["inv_drink_waterskin_12","1吉尔尼斯净水",75,1,30457,"消耗品",1.6],["inv_misc_food_05","1激流堡干酪",65,1,30458,"消耗品",4.18],["inv_fabric_netherweave","1灵纹布",60,1,21877,"",24.58],["inv_potion_131","1超级治疗药水",65,1,22829,"消耗品",1.38]];Table.create("dropItem");以上是一个WEB页面的源代码里的内容,我该如何对[["inv_drink_waterskin_12","1吉尔尼斯净水",75,1,30457,"消耗品",1.6],["inv_misc_food_05","1激流堡干酪",65,1,30458,"消耗品",4.18],["inv_fabric_netherweave","1灵纹布",60,1,21877,"",24.58],["inv_potion_131","1超级治疗药水",65,1,22829,"消耗品",1.38]]这一段里的数据进行每一个逗号里的详细读取?每一个[]里的逗号分开的各个数据还有那个[]与[]之间用逗号分开的算一条也就是说["inv_drink_waterskin_12","1吉尔尼斯净水",75,1,30457,"消耗品",1.6],["inv_misc_food_05","1激流堡干酪",65,1,30458,"消耗品",4.18],["inv_fabric_netherweave","1灵纹布",60,1,21877,"",24.58],["inv_potion_131","1超级治疗药水",65,1,22829,"消耗品",1.38]这些每条都单独读取 遍历过来 在最外面那个[]里的都遍历读取。这些每一条里的每一个逗号前的数据又要详细读取出来,要能够区分哪个是哪个,而且能操作。能写出代码供学习的话更好
 
我最后输出到一个listbox里了,你自己在listbox那里做自己想做的事就行了var strs,ss:tstringlist; str:string; i,j:integer;begin str:='[["inv_drink_waterskin_12","1吉尔尼斯净水",75,1,30457,"消耗品",1.6],'+ '["inv_misc_food_05","1激流堡干酪",65,1,30458,"消耗品",4.18],'+ '["inv_fabric_netherweave","1灵纹布",60,1,21877,"",24.58],'+ '["inv_potion_131","1超级治疗药水",65,1,22829,"消耗品",1.38]]'; strs:=tstringlist.Create; ss:=tstringlist.Create; try strs.Delimiter:='|'; ss.Delimiter:=','; delete(str,1,2); str:=copy(str,1,length(str)-2); str:=StringReplace(str,'"','',[rfReplaceAll]); str:=StringReplace(str,'],[','|',[rfReplaceAll]); strs.Delimiter:='|'; strs.DelimitedText:=str; for i:=0 to strs.Count-1 do begin ss.DelimitedText:=strs; if ss.Count<>7 then continue; listbox1.Items.Add(format('%s - %s - %s - %s - %s - %s - %s', [ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6]])); end; finally strs.Free; ss.Free; end;end;
 
非常感谢,又学会了一点。
 
后退
顶部