Silverlight Tips provides simple and useful tutorials and tips with real life examples, live demos and sample codes to download.
About authors:
Damon Serji
Damon Serji,
Silverlight developer working at Metia in London.
Gavin Wignall
Gavin Wignall,
Interactive Design Lead, working in design for over 10 years, the last 3 being in Silverlight.
Allan Muller
Allan Muller,
Developer, working on various types of Silverlight and WCF projects.
Recent comments

I have been looking around to find any built-in method to parse GUIDs in Silverlight, or to tell me if a value of type string is a valid GUID or not. After a few research I decided to create an Extension method to validate my GUID using Regular Expressions.

You can read more about Extension methods in Silverlight in my previous post here, but here I have a method to receive a string value and return true/false depending on if the sting value is a valid GUID or not. Anyway, here is what we can do to validate Silverlight GUID!

public static bool IsGUIDValid(string expression)
{
    if (expression != null)
    {
        Regex guidRegEx = 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})$");

        return guidRegEx.IsMatch(expression);
    }
    return false;
}

Posted by Damon Serji on 7. October 2009 16:17 under: Intermediate
 with 0 Comments

Comments

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview