I have a string like this:
"(list:\"RTM API\" status:completed)"
And I want to convert it into a NSDictionary with the “value” before the colon as the key and the value left of the colon as the value – like this:
list: "RTM API"
status: "completed"
It can probably be done using a simple regex or so, but I don’t really know how to do that.
I hope someone can explain a way to do this.
Thanks in advance.
How about this:
(\w+)\s*:\s*”([^”]+)”
Note that this won’t work with keys that have spaces or special characters. Only a-zA-Z0-9 (words). Plus you ALWAYS have to have quotes around values.
This will return two sets of results, one with all keys and one with all values.
I hope this helps.