Matching a Guid


using System;
using System.Text.RegularExpressions;


class Program
{
    static void Main(string[] args)
    {

         string r = 
            @"(?i)\b"               + 
            @"[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}"      + 
            @"\b"; 
    
         string text = "Its key is {11250410-fFff-ffD3-fA0C-0f0fEffCff01}."; 
         Console.WriteLine (Regex.Match (text, r).Index);             
   }
}

The output:


12
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.