【发布时间】:2018-09-05 22:23:07
【问题描述】:
我有一个这样的字符串
const str = 'map("a")to("b");map("foo")to("bar");map("alpha")to("beta");'
我想解析这个字符串以生成类似的 json
[{id: 'a', map: 'b'},
{id: 'foo', map: 'bar'},
{id: 'alpha', map: 'beta'}]
我想知道正则表达式是否是最好的方法,或者我是否可以利用任何实用程序库
【问题讨论】:
标签: javascript json regex string parsing