[已解决]如何选取特定位置的值?[感谢afan!]
本帖最后由 222222 于 2011-3-30 00:50 编辑以下数据中,因为每行中各参数的数值大小不同,因此每节的字符数也不同。现在想选取每行中"Girl": 后的名字(每行的名字长度不一),最有效率的选法是什么啊?
{"H":[{"P":[],"A":[],"SE":[],"Q":kiss,"U":0,"FM":936,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Tina,"FF":0,"GDP":36521}],"C":0,"R":0}
{"H":[{"P":[],"A":[],"SE":[],"Q":ear,"U":0,"FM":338,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Mary,"FF":0,"GDP":81163}],"C":0,"R":0}
{"H":[{"P":[],"A":[],"SE":[],"Q":foot,"U":0,"FM":508,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Cat,"FF":0,"GDP":63587}],"C":0,"R":0}
{"H":[{"P":[],"A":[],"SE":[],"Q":eye,"U":0,"FM":112,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Lina,"FF":0,"GDP":99999}],"C":0,"R":0}
{"H":[{"P":[],"A":[],"SE":[],"Q":hand,"U":0,"FM":855,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Away,"FF":0,"GDP":20000}],"C":0,"R":0} #include <Array.au3>
Local $Str = _
'{"H":[{"P":[],"A":[],"SE":[],"Q":kiss,"U":0,"FM":936,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Tina,"FF":0,"GDP":36521}],"C":0,"R":0}' & @CRLF & _
'{"H":[{"P":[],"A":[],"SE":[],"Q":ear,"U":0,"FM":338,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Mary,"FF":0,"GDP":81163}],"C":0,"R":0}' & @CRLF & _
'{"H":[{"P":[],"A":[],"SE":[],"Q":foot,"U":0,"FM":508,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Cat,"FF":0,"GDP":63587}],"C":0,"R":0}' & @CRLF & _
'{"H":[{"P":[],"A":[],"SE":[],"Q":eye,"U":0,"FM":112,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Lina,"FF":0,"GDP":99999}],"C":0,"R":0}' & @CRLF & _
'{"H":[{"P":[],"A":[],"SE":[],"Q":hand,"U":0,"FM":855,"DN":0,"M":null,"GO":"\/Happy\/","P":0,"Girl":Away,"FF":0,"GDP":20000}],"C":0,"R":0}'
Local $Test = StringRegExp($str, 'Girl":(\w+)', 3)
_ArrayDisplay($Test, UBound($Test))
回复 2# afan
谢谢afan!解决我一个难题。
果然,最有效率的是用正则表达式,会用正则表达式真的是很有高手风范!(默默地握紧拳头,下一步向正则表达式出发)
页:
[1]