文本处理问题,求大侠指导
假设有文本Bookmarks现在需要从文本中提取“name”和“URL”中对应的内容,生成一个新的文本文件,格式如下:
建议网站 https://ieonline.microsoft.com/#ieslice
百度一下,你就知道 https://www.baidu.com/
该怎么做?原文本内容如下:
{
"checksum": "1c0adc5c6af848e800513f5a475d3a1e",
"roots": {
"bookmark_bar": {
"children": [ {
"date_added": "13093172866258463",
"id": "6",
"name": "建议网站",
"type": "url",
"url": "https://ieonline.microsoft.com/#ieslice"
}, {
"date_added": "13102131540804891",
"id": "7",
"name": "百度一下,你就知道",
"type": "url",
"url": "https://www.baidu.com/"
}, {
"date_added": "13102153780201735",
"id": "11",
"name": "搜狐",
"type": "url",
"url": "http://www.sohu.com/"
} ],
"date_added": "13102131354410490",
"date_modified": "13102154205871494",
"id": "1",
"name": "书签栏",
"type": "folder"
},
"other": {
"children": [ {
"date_added": "13102153748098092",
"id": "10",
"name": "新浪",
"type": "url",
"url": "http://www.sina.com/"
} ],
"date_added": "13102131354410498",
"date_modified": "13102153748098092",
"id": "2",
"name": "其他书签",
"type": "folder"
},
"synced": {
"children": [],
"date_added": "13102131354410499",
"date_modified": "0",
"id": "3",
"name": "移动设备书签",
"type": "folder"
}
},
"version": 1
} 正则提取
(?i)"name":\h*"([^"]+)[^/}]+?"url":\h*"([^"]+) 楼上腻害。正则我都忘的差不多了,好久不用了。 正则提取
(?i)"name":\h*"([^"]+)[^/}]+?"url":\h*"([^"]+)
afan 发表于 2016-3-11 17:59 http://www.autoitx.com/images/common/back.gif
A大正则中,这是第一个能看明白的表达式....{:face (411):}
除了 (?i) 不明确意思..... 回复 4# Huiseyu
好嘛,有进步~~(?i) 不区分大小写
页:
[1]