heavenm 发表于 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+"是不行的

heavenm 发表于 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, '"(\d*)",?', 3)
_ArrayDisplay($c, "活动窗口包含的'类'列表")

haodd 发表于 2013-4-21 15:12:11

你的答案已经很接近了 努力

kevinch 发表于 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这样试下

heavenm 发表于 2013-4-21 20:14:12

= =#在比较大量的数据下,4楼的正则没什么用处,会卡死
可能代码太多了,
是淘宝页面的源码,暂时用2次提取的方法解决了,期待更强的正则!

haijie1223 发表于 2013-4-22 09:50:08

\"(\d+)\"|\d+\.\d+
页: [1]
查看完整版本: 正则,提取方括号内,数据表怎么做?