Click here to Skip to main content
13,249,813 members (65,675 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

I am using MVC4 and WCF. can anybody pls tell me how to give Regular expression for GUID.

Thanking you.
Posted 9-Jul-12 1:07am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

An empty Guid is always the same value: 00000000-0000-0000-0000-000000000000
So the Regex would be trivial:

Why do I get the feeling this is not the question you meant to ask?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try this:

public static bool IsGUID(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;
Prasad_Kulkarni 13-Jul-12 0:07am
My 5!
Manas Bhardwaj 13-Jul-12 3:45am
thx Prasad. btw I have a (free) full one month subscription for PluralSight, if you are interested let me know :)
Prasad_Kulkarni 13-Jul-12 5:45am
Of course I am, Glad to hear that. What do I need to do, means how I can get access of it.
Manas Bhardwaj 13-Jul-12 5:50am
Will pass on the details this weekend.
Prasad_Kulkarni 13-Jul-12 5:52am
That's so nice. Excited!!!!! will learn sooo many new things.
Manas Bhardwaj 13-Jul-12 5:52am
Nothing. I'll send you the subscription id :)
Prasad_Kulkarni 13-Jul-12 5:53am
Thank you thank you thank you soooo much..
Prasad_Kulkarni 13-Jul-12 6:02am
Sure. Just a moment..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 9 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100