How can I parse multiple values from a formatted string in C#?
The string is in this format:
“blah blah blah (foo:this, bar:that)”
I need to parse out the foo and the bar value. The parentheses are always at the end of the line.
Edit: Sorry… that wasn’t very clear. What I meant was I need to know the “foo” value and the “bar” value, so that I can say, somewhere else, “foo is this” and “bar is that”.
Thanks
EDIT: updated after OP clarification.
This should do:
This outputs:
If you need to ensure the match only occurs at the end of the string, rather than match similar formatted values elsewhere in the string, add
$to the end of the pattern: