Thursday, August 5, 2010

Here's some code (c#) to test for a GUID using a regular expression:

Regex isGuid = 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}$", RegexOptions.Compiled);
if (isGuid.IsMatch(owner))
{
ownerId = new Guid(owner);
}

Have fun...

No comments:

Post a Comment