菜鸟求助,Regex.IsMatch正则表达式不认中文的问题
很奇怪的问题,我这样写
string[] sentences = { "你", "x" }; bool find = false; string sPattern = this.content.Text; foreach (string s in sentences) { if (System.Text.RegularExpressions.Regex.IsMatch(sPattern,s)) { //找到了 } else { //没有找到 }
FileStream fs = new FileStream(Server.MapPath(".")+"\\test1.txt",FileMode.Open,FileAccess.Read); StreamReader sr = new StreamReader(fs); string[] words= sr.ReadToEnd().Split('|'); bool find = false; string sPattern = this.content.Text; foreach (string s in words) { if (System.Text.RegularExpressions.Regex.IsMatch(sPattern,s)) { //找到了 } else { //没有找到 }