bool IsEmptyOrError(string str)
{
Regex regex1 = new Regex(@"[a-zA-z]+://[^s]*"); // 匹配网址
Regex regex2 = new Regex(@"[/\\^%&',;=?$\x22]+"); // 匹配特殊字符
Regex regex3 = new Regex(@"[()()a-zA-z0-9\u4e00-\u9fa5]+");
if (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str)
|| regex1.IsMatch(str) || regex2.IsMatch(str) || !regex3.IsMatch(str))
{
return true;
}
return false;
}
C#判断字符串是否合法
最新推荐文章于 2024-12-14 17:12:17 发布