tubaba 发表于 2012-8-19 15:01:33

求助一正则的写法(已解决)

本帖最后由 tubaba 于 2012-8-19 22:11 编辑

想用正则来提取csv文件每一项的值,如
"8",",","怡","401001","15008","255.255.255.49","3402",""",""","20120621"

要求提取后为

头很疼,应该如何写?

kevinch 发表于 2012-8-19 15:56:33

#include <array.au3>
$str='"8",",","怡","401001","15008","255.255.255.49","3402",""",""","20120621"'
$regexp=ObjCreate("vbscript.regexp")
With $regexp
        .global=1
        .pattern='"(("*)([^"]*)\2)"'
        If .test($str) Then
                $arr=.execute($str)
                Dim $result[$arr.count],$n
                $n=0
                For $match In $arr
                        $result[$n]=StringReplace($match.submatches(0),'""','"')
                        $n+=1
                Next
                _ArrayDisplay($result)
        EndIf
EndWith
$regexp=0

tubaba 发表于 2012-8-19 21:26:50

本帖最后由 tubaba 于 2012-8-19 22:10 编辑

谢谢,果然高手如林啊,~~,如果只用正则和sringreplace不知道该如何实现

找到答案了,http://www.autoitx.com/thread-29704-2-1.html
页: [1]
查看完整版本: 求助一正则的写法(已解决)