Questions tagged «taskwarrior»

1
RegEx使用RegExp.exec从字符串中提取所有匹配项
我正在尝试解析以下类型的字符串: [key:"val" key2:"val2"] 里面有任意键:“ val”对。我想获取键名和值。对于那些好奇的人,我想解析任务战士的数据库格式。 这是我的测试字符串: [description:"aoeu" uuid:"123sth"] 这是要强调的是,除了空格之外,任何其他内容都可以位于键或值中,冒号周围没有空格,并且值始终用双引号引起来。 在节点中,这是我的输出: [deuteronomy][gatlin][~]$ node > var re = /^\[(?:(.+?):"(.+?)"\s*)+\]$/g > re.exec('[description:"aoeu" uuid:"123sth"]'); [ '[description:"aoeu" uuid:"123sth"]', 'uuid', '123sth', index: 0, input: '[description:"aoeu" uuid:"123sth"]' ] 而且description:"aoeu"也符合这种模式。我如何找回所有比赛?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.