在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
如何判断一下字符串是不是能转化成guid /// <summary> /// 判断字符串是否可以转为Guid /// </summary> /// <param name="str">字符串</param> /// <returns></returns> public bool IfStr2Guid(string str) { bool IsCan = false; str = str.ToLower();//可以不用 //var regexStr1 = string.Format(@"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$|^[0-9a-f]{32}$ ");//允许没有'-' //var regexStr2 = string.Format(@"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$ "); Match m = Regex.Match(str, @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$|^[0-9a-f]{32}$ ", RegexOptions.IgnoreCase);//忽略大小写 if (m.Success) { IsCan = true; } return IsCan; }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论