找回密码
 加入
搜索
查看: 4357|回复: 5

[系统综合] 正则,提取方括号内,数据表怎么做?

  [复制链接]
发表于 2013-4-21 14:14:46 | 显示全部楼层 |阅读模式
auctionNids":["16824023912","16761246460","14944173629","13511670394","15536062842","14758243672","14758343048","21356884083","21224068570","15773010936","23107384071","22775032679","17359798874","20199800852","17743981141","24131676753","24040988146","15969622250","17834434672","20048916441","17046344996","22344824407","16782337122","22750432657","17395282270","20051792360","19676167575","18988259947","23720656187","23903620831","22993536712","23197792280","21192200706","18001765104","19696615912","17267366574","24131504759","18077405276","22947236975","19545279506"]
auctionPrices":["1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.08","4.35","4.35","4.40","4.45","4.45","4.45","4.45","4.45","4.45","4.46","4.49","4.49","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50"]
怎么把方括号里面的数字都提取出来?
有很多这样子的格式在,一个文件里面,所以
"\d+"是不行的
 楼主| 发表于 2013-4-21 14:56:47 | 显示全部楼层
貌似只能提取2次啦!
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Array.au3>
$a='auctionNids":["16824023912","16761246460","14944173629","13511670394","15536062842","14758243672","14758343048","21356884083","21224068570","15773010936","23107384071","22775032679","17359798874","20199800852","17743981141","24131676753","24040988146","15969622250","17834434672","20048916441","17046344996","22344824407","16782337122","22750432657","17395282270","20051792360","19676167575","18988259947","23720656187","23903620831","22993536712","23197792280","21192200706","18001765104","19696615912","17267366574","24131504759","18077405276","22947236975","19545279506"]auctionPrices":["1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.08","4.35","4.35","4.40","4.45","4.45","4.45","4.45","4.45","4.45","4.46","4.49","4.49","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50"'
$b=StringRegExp ($a, 'auctionNids":\[(.*?)\]', 3)
$c=StringRegExp ($b[0], '"(\d*)",?', 3)
_ArrayDisplay($c, "活动窗口包含的'类'列表")
发表于 2013-4-21 15:12:11 | 显示全部楼层
你的答案已经很接近了 努力
发表于 2013-4-21 15:26:19 | 显示全部楼层
#include <array.au3>
$str='auctionNids":["16824023912","16761246460","14944173629","13511670394","15536062842","14758243672","14758343048","21356884083","21224068570","15773010936","23107384071","22775032679","17359798874","20199800852","17743981141","24131676753","24040988146","15969622250","17834434672","20048916441","17046344996","22344824407","16782337122","22750432657","17395282270","20051792360","19676167575","18988259947","23720656187","23903620831","22993536712","23197792280","21192200706","18001765104","19696615912","17267366574","24131504759","18077405276","22947236975","19545279506"]' & @CRLF & _
        'auctionPrices":["1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.00","1.08","4.35","4.35","4.40","4.45","4.45","4.45","4.45","4.45","4.45","4.46","4.49","4.49","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50","4.50"]'
$arr=StringRegExp($str,"(\d+(?:\.\d+)?)(?=[^\[\]]*?\])",3)
If Not @error Then
        _ArrayDisplay($arr)
EndIf
这样试下
 楼主| 发表于 2013-4-21 20:14:12 | 显示全部楼层
= =#在比较大量的数据下,4楼的正则没什么用处,会卡死
可能代码太多了,
是淘宝页面的源码,暂时用2次提取的方法解决了,期待更强的正则!
发表于 2013-4-22 09:50:08 | 显示全部楼层
"(\d+)"|\d+\.\d+
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-25 13:45 , Processed in 0.068553 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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