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

[效率算法] 求会正则的大神,我看起来头疼。。。

[复制链接]
发表于 2015-2-14 15:48:25 | 显示全部楼层 |阅读模式
本帖最后由 devineresse 于 2015-2-15 09:45 编辑

_ntes_quote_callback({"1000002":{"code": "1000002", "percent": 0.023256, "high": 13.01, "askvol3": 100600, "askvol2": 76860, "askvol5": 226673, "askvol4": 60700, "price": 12.76, "open": 12.54, "bid5": 12.71, "bid4": 12.72, "bid3": 12.73, "bid2": 12.74, "bid1": 12.75, "low": 12.33, "updown": 0.29, "type": "SZ", "bidvol1": 227400, "status": 0, "bidvol3": 111400, "bidvol2": 11500, "symbol": "000002", "update": "2015/02/13 15:36:42", "bidvol5": 350000, "bidvol4": 613000, "volume": 196804327, "askvol1": 70201, "ask5": 12.8, "ask4": 12.79, "ask1": 12.76, "name": "\u4e07  \u79d1\uff21", "ask3": 12.78, "ask2": 12.77, "arrow": "\u2191", "time": "2015/02/13 15:36:36", "yestclose": 12.47, "turnover": 2503342411.83} });


上面是一段股票接口回测代码,现在需要把中括号里面的弄成2列n行的数组。上面的逗号是分对的,冒号是对应的一对。如:array[0][0]=["code","1000002"]……
发表于 2015-2-14 18:15:04 | 显示全部楼层

#include <Array.au3>
$txt = '_ntes_quote_callback({"1000002":{"code": "1000002", "percent": 0.023256, "high": 13.01, "askvol3": 100600, "askvol2": 76860, "askvol5": 226673, "askvol4": 60700, "price": 12.76, "open": 12.54, "bid5": 12.71, "bid4": 12.72, "bid3": 12.73, "bid2": 12.74, "bid1": 12.75, "low": 12.33, "updown": 0.29, "type": "SZ", "bidvol1": 227400, "status": 0, "bidvol3": 111400, "bidvol2": 11500, "symbol": "000002", "update": "2015/02/13 15:36:42", "bidvol5": 350000, "bidvol4": 613000, "volume": 196804327, "askvol1": 70201, "ask5": 12.8, "ask4": 12.79, "ask1": 12.76, "name": "\u4e07??\u79d1\uff21", "ask3": 12.78, "ask2": 12.77, "arrow": "\u2191", "time": "2015/02/13 15:36:36", "yestclose": 12.47, "turnover": 2503342411.83} });'
$a = StringRegExp($txt, "(?<={)[^{]*?(?=})", 3)
$b = StringSplit($a[0], ",")
Dim $c[$b[0]][2]
For $i = 1 To $b[0]
        $d = StringSplit($b[$i], ":")
        $c[$i-1][0] = $d[1]
        $c[$i-1][1] = $d[2]
Next
_ArrayDisplay($c)

评分

参与人数 1金钱 +10 收起 理由
devineresse + 10 我很赞同

查看全部评分

 楼主| 发表于 2015-2-15 09:43:04 | 显示全部楼层
谢谢完美。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 11:58 , Processed in 0.069131 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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