C# Split 根据组合字符进行拆分数组用法

时间:2024-05-04 13:06:01

C# Split 根据组合字符进行拆分数组用法,如下代码:

string sql = "aaaaaaaaaa{@}bbbbbbbbbb{@}ccccccc#cccccc";
//1、单组合{@}拆分
string[] separator = new string[] { "{@}" };
//2、多组合{@}、#拆分
string[] separator1 = new string[] { "{@}", "#" };
string[] arry = sql.Split(separator, StringSplitOptions.RemoveEmptyEntries);
string[] newArry = sql.Split(new string[] { "{-<@>-}" }, StringSplitOptions.RemoveEmptyEntries);