62,052
社区成员
发帖
与我相关
我的任务
分享
List<string> list = new List<string>();
string str = "(苹果||鸭梨)&&(鸡蛋||鸭蛋)!香蕉&&(电视||笔记本)";
Regex reg = new Regex(@"[\u4E00-\u9FA5]+");
foreach (Match m in reg.Matches(str))
{
list.Add(m.Value);
}
foreach (string s in list)
{
Response.Write(s + "<br/>");
}
Regex MyRegex = new Regex("[^\\u4e00-\\u9fa5a-zA-Z] ", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
string result = MyRegex.Replace(@"(苹果||鸭梨)&&(鸡蛋||鸭蛋)!香蕉&&(电视||笔记本)", " ");
List<string> lt = new List<string>();
lt = result.Split(' ').ToList().ToList<string>();
for (int i = 0; i < lt.Count; i++)
{
Response.Write(lt[i].ToString()+"<br/>");
}
Regex MyRegex = new Regex("[^\\u4e00-\\u9fa5a-zA-Z] ", RegexOptions.IgnoreCase|RegexOptions.CultureInvariant|RegexOptions.IgnorePatternWhitespace|RegexOptions.Compiled);
string result = MyRegex.Replace(@"(苹果||鸭梨)&&(鸡蛋||鸭蛋)!香蕉&&(电视||笔记本)", " ");
Response.Write(result.ToString());