I am looking for a way to find a Guid within a string that is in a .NET recognizable pattern.
There are a few regex’s available in this popular library, but I can’t find one that works for all of the possible Guids outlined here in this MSDN article.
For example, lets say I have a string like this:
ACTIVITY: “{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}”, Time:09:09:09:09
This should return:
{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}
Another example could be:
Random string CA761232-ED42-11CE-BACD-00AA0057B223 random string
This should return:
CA761232-ED42-11CE-BACD-00AA0057B223
Any ideas on how to approach this? Is regular expressions the way to go here?
Solution is:
See and test this code here.