public bool MatchWord(string temp)
{
string excludeString = @"!@%^*()={};~`<>,?\|";
Regex excludeRegex = new Regex(@"[" + excludeString + "]", RegexOptions.Compiled);
return excludeRegex.IsMatch(temp);
}当传入temp = @“\";
返回false,其特殊字符他都返回true
修改程序public bool MatchWord(string temp)
{
string excludeString = @"!@%^*()={};~`<>,?\\|";
Regex excludeRegex = new Regex(@"[" + excludeString + "]", RegexOptions.Compiled);
return excludeRegex.IsMatch(temp);
}返回值正常,想问问这是为什么呢??我用了@为什么还要用\\呢?
解决方案 »
- C# 一个二维数组读取截取字符串的问题
- asp.net 后台添加数据时 提示DBHelper.cs 类出现为题
- 短信猫中删除短信的问题
- 请问 怎么样用代码 打开 sidebar 小工具 窗体?
- 请求会C#和oracle技术的达人诊断诊断merge into的问题
- 新手请教,子类,父类
- (在线求解) 请问:怎么让dataGrid控件中的一列,不能获得焦点! 例如:
- 我的程序为什么要用 .net 来开发(WinForm)?
- 求一段C#里考试倒计时的程序 祝大家 圣诞 元旦快乐
- 关于Mdi窗体的两个问题?1.如何在mdi窗体中加载背景图片.2....?
- 切图问题
- winform下用户控件重新加载的问题?
public bool MatchWord(string temp)
{
string excludeString = @"!@%^*()={};~`<>,?\|";
Regex excludeRegex = new Regex(@"[" + excludeString + "]", RegexOptions.Compiled);
return excludeRegex.IsMatch(temp);
}当传入temp = @“\";
返回false,其特殊字符他都返回true
修改程序public bool MatchWord(string temp)
{
string excludeString = @"!@%^*()={};~`<>,?\\|";\\此处将\改为\\
Regex excludeRegex = new Regex(@"[" + excludeString + "]", RegexOptions.Compiled);
return excludeRegex.IsMatch(temp);
}返回值正常,想问问这是为什么呢??我用了@为什么还要用\\呢?