I have this string:
metadata=1.2 name=stone:supershare UUID=eff4e7bc:47aea5cf:0f0560f0:2de38475
I wish to extract from it the key and value pairs: <key>=<value>
.
/(\w+)=(.+?)\s/g
This, as expected, doesn't return the UUID
pair, due to not being followed by space:
[
"metadata=1.2 ",
"name=stone:supershare "
],
[
"metadata",
"name"
],
[
"1.2",
"stone:supershare"
]
Now, obviously, we should make the \s
lookup optional:
/(\w+)=(.+?)\s?/g
Though, this goes utterly nuts extracting only the first symbol from value
:
[
"metadata=1",
"name=s",
"UUID=e"
],
[
"metadata",
"name",
"UUID"
],
[
"1",
"s",
"e"
]
I am kind of lost, what am I doing wrong here?