Use regualr expression to check if a string is a GUID
//New BSD License (BSD)
//http://bluecms.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace BlueCMS.Core.Extensions
{
public static class StringExtensions
{
private static 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);
public static bool IsGuid(this string @this)
{
return _isGuid.IsMatch(@this);
}
}
}
Related examples in the same category