找回密码
 加入
搜索
查看: 2127|回复: 2

[AU3基础] [已解决]如何选取特定位置的值?[感谢afan!]

[复制链接]
发表于 2011-3-29 21:43:59 | 显示全部楼层 |阅读模式
本帖最后由 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}
发表于 2011-3-29 21:52:07 | 显示全部楼层
#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))
 楼主| 发表于 2011-3-29 22:03:34 | 显示全部楼层
回复 2# afan


   谢谢afan!解决我一个难题。

  果然,最有效率的是用正则表达式,会用正则表达式真的是很有高手风范!(默默地握紧拳头,下一步向正则表达式出发)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 01:26 , Processed in 0.075467 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表