I’m having trouble creating a Regex to match either a GUID or an error message from a response stream.
For example, the response is either:
{ "uuid": "8e5b0721-26c4-11df-b354-002170de47d3" }
or
{ "error": "<--Error Message-->" }
I have the Regex for a GUID:
new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$"
But I’m not entirely sure that the response will always be a GUID.
I guess I’m looking for a GUID that will return a the contents of the second set of quotation marks regardless of type.
This is a json format string.
Instead of using regex to get the data, use a json parer instead.
Check DataContractJsonSerializer Class