With a string like {float: 'null', another: 'foo'}
, I’d like to grab each set of key/values pairs so that the groups would output float
null
, and another
and foo
.
My current regex is /{(?<set>(?<key>w*)s*:s*(?<value>.*)?s?)*}/g
It grabs the key correctly, but anything past from the comma on receives it as the value. I’m using named groups mainly just for clarity. Can’t figure out how to extract each key/value pair especially when there are multiple.
Thanks for any help
Currently am trying /{(?<set>(?<key>w*)s*:s*(?<value>.*)?s?)*}/g
but the output is:
the group ‘set’: float: 'null', another: 'foo'
(correct)
the group ‘key’: float
(correct)
the group ‘value’: 'null', another: 'foo'
(incorrect, I want just null
)
Would like it to capture all key/value pairs if possible