I have the following input:
-key1:"val1" -key2: "val2" -key3:(val3) -key4: "(val4)" -key5: val5 -key6: "val-6" -key-7: val7 -key-eight: "val 8"
With only the following assumption about the pattern:
- Keys always start with a
-followed by a value delimited by:
How can I match and extract each key and it's corresponding value?
I have so far come up with the following regex:
-(?<key>\S*):\s?(?<val>\S*)
But it's currently not matching the complete value for the last argument as it contains a space but I cannot figure out how to match it.
The expected output should be:
- key1 "val1"
- key2 "val2"
- key3 (val3)
- key4 "(val4)"
- key5 val5
- key6 "val-6"
- key-7 val7
- key-eight val 8
Any help is much appreciated.