找回密码
 加入
搜索
查看: 1853|回复: 7

[AU3基础] 请教下,大神来帮我看下正则问题

    [复制链接]
发表于 2018-5-6 16:06:55 | 显示全部楼层 |阅读模式
本帖最后由 zxw91 于 2018-5-6 16:10 编辑
{
   "checksum": "4239e31da4bc38769c0968e4a5404660",
   "roots": {
      "bookmark_bar": {
         "children": [ {
            "data_ico": "13170067090600011",
            "date_added": "0",
            "id": "6",
            "is_best": 0,
            "name": "谷歌",
            "type": "url",
            "url": "http://www.google.com.hk/search?client=aff-cs-360se-channel&channel=bookmark&q="
         }, {
            "data_ico": "13170067090600034",
            "date_added": "0",
            "id": "7",
            "is_best": 0,
            "name": "网址大全",
            "type": "url",
            "url": "https://hao.360.cn/?src=bm"
         }, {
            "data_ico": "13170067090600050",
            "date_added": "0",
            "id": "8",
            "is_best": 0,
            "name": "360搜索",
            "type": "url",
            "url": "https://www.so.com/?src=se_favorite"
         }, {
            "data_ico": "13170067090600068",
            "date_added": "0",
            "id": "9",
            "is_best": 0,
            "name": "游戏中心",
            "type": "url",
            "url": "http://wan.360.cn/?src=se-scj-top01&channel=515460173"
         }, {
            "children": [ {
               "data_ico": "0",
               "date_added": "13169620471999500",
               "id": "18",
               "is_best": 0,
               "name": "2345网址导航",
               "type": "url",
               "url": "http://www.2345.cn/"
            }, {
               "data_ico": "0",
               "date_added": "13169620471999500",
               "id": "19",
               "is_best": 0,
               "name": "360导航",
               "type": "url",
               "url": "http://hao.360.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169999741860351",
               "id": "20",
               "is_best": 0,
               "name": "京东商城",
               "type": "url",
               "url": "http://www.jingdong.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169999741875976",
               "id": "21",
               "is_best": 0,
               "name": "天猫商城",
               "type": "url",
               "url": "http://www.tianmao.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169999741860351",
               "id": "22",
               "is_best": 0,
               "name": "淘宝网",
               "type": "url",
               "url": "http://www.taobao.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169999741860351",
               "id": "23",
               "is_best": 0,
               "name": "百度一下",
               "type": "url",
               "url": "http://www.baidu.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169999741875976",
               "id": "24",
               "is_best": 0,
               "name": "网页游戏",
               "type": "url",
               "url": "http://wan.2345.com/tuiguang3/index_11.html"
            } ],
            "date_added": "13170067085941494",
            "date_modified": "0",
            "id": "17",
            "name": "Links for 中国",
            "type": "folder"
         }, {
            "children": [ {
               "data_ico": "0",
               "date_added": "13169620472015125",
               "id": "26",
               "is_best": 0,
               "name": "2345网址导航",
               "type": "url",
               "url": "http://www.2345.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169620472015125",
               "id": "27",
               "is_best": 0,
               "name": "360导航",
               "type": "url",
               "url": "http://hao.360.cn/"
            }, {
               "data_ico": "0",
               "date_added": "13169938945132812",
               "id": "28",
               "is_best": 0,
               "name": "京东商城",
               "type": "url",
               "url": "http://www.jd.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169938945135742",
               "id": "29",
               "is_best": 0,
               "name": "天猫商城",
               "type": "url",
               "url": "http://www.tm.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169938945135742",
               "id": "30",
               "is_best": 0,
               "name": "淘宝网",
               "type": "url",
               "url": "http://www.taobao.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169620615826648",
               "id": "31",
               "is_best": 0,
               "name": "百度一下",
               "type": "url",
               "url": "http://www.baidu.com/"
            }, {
               "data_ico": "0",
               "date_added": "13169620615826648",
               "id": "32",
               "is_best": 0,
               "name": "网页游戏",
               "type": "url",
               "url": "http://wan.2345.com/tuiguang3/index_11.html"
            } ],
            "date_added": "13170067085942276",
            "date_modified": "0",
            "id": "25",
            "name": "收藏夹栏",
            "type": "folder"
         } ],
         "date_added": "13118141548647143",
         "date_modified": "0",
         "id": "1",
         "name": "收藏栏",
         "showfolderid": 0,
         "type": "folder"
      },
      "other": {
         "children": [  ],
         "date_added": "13118141548647149",
         "date_modified": "0",
         "id": "2",
         "name": "其他收藏",
         "type": "folder"
      },
      "synced": {
         "children": [  ],
         "date_added": "13118141548647150",
         "date_modified": "0",
         "id": "3",
         "name": "手机收藏夹",
         "type": "folder"
      }
   },
   "version": 1
}
请教各位大神我想用AU3的正则表达式获取到出现的第一个children 到第二个children之间的内容,就是第5行到第38行间的内容。正则该怎么写?
发表于 2018-5-6 16:26:14 | 显示全部楼层
(?si)^.*?\v(\h*"children":.+?)(?=\v+\h*"children")
 楼主| 发表于 2018-5-6 16:47:36 | 显示全部楼层
回复 2# afan
#include <MsgBoxConstants.au3>
$myFile =@ScriptDir&'\Bookmarks.txt'
$filehandle = FileOpen($myFile,0)
$content = FileRead($myFile)
$str =StringRegExpReplace($content, '(?si)^.*?\v(\h*"children":.+?)(?=\v+\h*"children")', "$1")
MsgBox(0, "", $str)
,你好,测试了下,还是没获正确
发表于 2018-5-6 18:20:22 | 显示全部楼层
大神的正则你也质疑?要不就是你没表达清楚.如果你只是要第六行和第三十七行的,(?si)^.*?\v(\h*""data_ico":":.+?)(?=\v+\h*"children")  就这样改.
 楼主| 发表于 2018-5-6 18:31:31 | 显示全部楼层
谢谢上面的两位,已经成功了  (?si)^.*?\v(\h*"children":.+?)(?=\v+\h*"children").*   在后面加个.* 就是自己想要的结果
发表于 2018-5-7 11:01:12 | 显示全部楼层
代码看着好难啊
发表于 2018-5-7 20:41:40 | 显示全部楼层
同求正则
发表于 2018-5-8 09:46:34 | 显示全部楼层
学习学习中
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-19 12:16 , Processed in 0.073638 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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