关于C#字符串按照小括号拆分报错问题

来源:互联网 发布:织梦if标签 编辑:程序博客网 时间:2024/06/04 19:14

字符串按字符拆分直接用string.Split('str')即可。

但是按照小括号拆分时,报解析错。

解决方法如下:(这个案例可按照字符串拆分)

string str = "(dasdfaowe],{}(fhweo],fdf";
string[] sA = System.Text.RegularExpressions.Regex.Split(str, "\\(", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string[] sB = System.Text.RegularExpressions.Regex.Split(str, "{}", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string[] sC = System.Text.RegularExpressions.Regex.Split(str, "]", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
  

不知道为什么,但是就这么出现问题。