判断是否GUID (转载)
转载自:http://www.cnblogs.com/kiddo/archive/2008/04/16/1156295.html
判断是否GUID
public bool IsGUID(string str)
{
Match m = Regex.Match(str, @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase);
if (m.Success)
{
//可以转换
//Guid guid = new Guid(str);
return true;
}
else
{
//不可转换
return false;
}
}
{
Match m = Regex.Match(str, @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase);
if (m.Success)
{
//可以转换
//Guid guid = new Guid(str);
return true;
}
else
{
//不可转换
return false;
}
}