0

*.session.という名前のFirefoxセッションマネージャーが保存したファイルがたくさんあり、ファイルからURLとタイトルをエクスポートしたいので、正規表現を書きました:

(?<=entries":\[{"url":"(?<link>.*?(?="))","title":"(?<content>.*?)(?=",")) 

しかし、うまくいかないようです。似合いすぎた。

ファイルのパーティー

[SessionManager v2]
name=jjjjjjjjjjjjjjjjjj
timestamp=1368030038170
autosave=false  count=1/49  screensize=1366x768
{"windows":[{"tabs":[{"entries":[{"url":"http://blog.csdn.net/gisfarmer/article/details/4135975?1357376310","title":"图像相似度算法的C#实现及测评 - 老骆驼空间站 - 博客频道 - CSDN.NET","ID":1673113085,"docshellID":36,"referrer":"http://blog.csdn.net/gisfarmer/article/details/4135975","docIdentifier":80,"children":[{"url":"about:blank","ID":1673113086,"docshellID":34,"docIdentifier":81},{"url":"about:blank","ID":1673113087,"docshellID":168,"docIdentifier":82},{"url":"about:blank","ID":1673113088,"docshellID":55,"docIdentifier":83},{"url":"about:blank","ID":1673113089,"docshellID":37,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":84},{"url":"about:blank","ID":1673113090,"docshellID":31,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":85},{"url":"about:blank","ID":1673113091,"docshellID":63,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":86},{"url":"about:blank","ID":1673113092,"docshellID":22,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":87},{"url":"about:blank","ID":1673113093,"docshellID":118,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":88},{"url":"about:blank","ID":1673113094,"docshellID":59,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":89},{"url":"about:blank","ID":1673113095,"docshellID":137,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQWh0dHA6Ly9ibG9nLmNzZG4ubmV0L2dpc2Zhcm1lci9hcnRpY2xlL2RldGFpbHMvNDEzNTk3NT8xMzU3Mzc2MzEwAAAAAAAAAAQAAAAHAAAADQAAAAf/////AAAAB/////8AAAAHAAAADQAAABQAAAAtAAAAFAAAACIAAAAUAAAAGwAAAC8AAAAHAAAAL/////8AAAAA/////wAAADcAAAAKAAAAFP////8BAAAAAAAAAAAAAQAAAAAAAA==","docIdentifier":90},{"url":"about:blank","ID":1673113096,"docshellID":254,"owner_b64":"CbflmEkNQj+opi5sTsh3UAAAAAAAAAAAwAAAAAAAAEYB3pRy0IA0EdOTmQAQS6D9QDlf4EV9GErbo/2vmMihrxEAAAAC/////wAAAFABAAAAQW

と結果 ここに画像の説明を入力

助けることができる任意の体!

4

2 に答える 2

7

正規表現を使用せずにjsonを解析してループスルーしてみませんか?

于 2013-07-09T04:32:30.367 に答える
3

マット・ブライアントのやり方が一番良さそうです。正規表現の問題では、次を使用できます。

"url":"(?<link>[^"]+)","title":"(?<content>[^"]+)

またはより多くのセキュリティのために

"url":"(?<link>(?>[^"]+|(?<=\\)")+)","title":"(?<content>(?>[^"]+|(?<=\\)")+)
于 2013-07-09T04:42:17.600 に答える