using System;
using System.Text.RegularExpressions;
namespace test_yanzhengzifu
{
/// <summary>
/// yanzheng 的摘要说明。
/// </summary>
public class yanzheng
{
/// <summary>
/// 严整特殊字符
/// </summary>
public static bool checkString(string source)
{
Regex regExp=new Regex("[~!@#$%^&*()=+[//]{}'/";:/?.,><`|!·¥…—()//-、;:。,》《]");
return !regExp.IsMatch(source);
}
}
}
本文介绍了一个使用C#实现的特殊字符验证方法。该方法通过正则表达式检查字符串中是否包含指定的特殊字符集,如~、!、@等,并返回一个布尔值以表明字符串是否通过验证。此功能对于确保输入数据的质量非常有用。
1万+

被折叠的 条评论
为什么被折叠?



