Guid正则验证

 /// <summary>
        /// Guid格式验证
        /// </summary>
        /// <param name="id">Guid</param>
        /// <returns></returns>
        public static bool VerificationGuid(Guid id)
        {
            Match match = Regex.Match(id.ToString(), @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                return true;
            }
            return false;
        }

你可能感兴趣的:(Guid正则验证)