如何使用正则表达式将 csv 字符串转换为 JSON 数组?
我正在尝试将正则表达式与 Vim 或 Sublime Text 等文本编辑器一起使用,而不是与编程语言一起使用。仅供参考,Sublime Text 使用Boost 语法。
如果我有一组这样的 csv 字符串:
"tag1, tag2, tag3"
上面的字符串格式应如下所示:
["tag1", "tag2", "tag3"]
(添加了对整个内容的解释......)
csv 字符串位于内容的中间,如下所示:
...
{"url":"http://osxdaily.com/2007/0ge5/02/quickly-encrypt-a-file-with-openssl",
"user":"user01","tag_string":"openssl,encrypt",
"created_at":"2011/04/19 05:49:26 +0000",
"title":"Quickly encrypt a file with OpenSSL"},
{"url":"http://staticimport.blogspot.com","user":"user02",
"tag_string":"command,line,developer,tools,osx",
"created_at":"2011/04/19 05:42:13 +0000","title":"Mac OS X Lion Command Line Developer Tools staticimport"},
{"url":"https://developer.apple.com/downloads/index.action",
"user":"user_01","tag_string":"ios,development,download",
"created_at":"2011/04/19 04:47:26 +0000","title":"Apple Developer Download Center"}
...
tag_string是要转换为 JSON 数组的 csv 字符串。