I am new to regular expressions. I am trying to parse the following string type:
[key:"val" key2:"val2"]
where there is an arbitrary key: pairs "val" inside. I want to get the name and value of the key. For the curious, I am trying to parse the format of the warrior database of a task. Here is my test line:
[description:"aoeu" uuid:"123sth"] , which is intended to emphasize that something can be in the key or value aside from space, without spaces around the colons, and the values ββare always enclosed in double quotes. In node, this is my conclusion:
[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"]' ]
But description:"aoeu" also matches this pattern. How can I return all matches?
javascript regex regex-group taskwarrior
gatlin Jun 12 '11 at 17:27 2011-06-12 17:27
source share