C#中Split分隔字符串的应用(C#、split、分隔、字符串)

时间:2023-03-10 04:57:45
C#中Split分隔字符串的应用(C#、split、分隔、字符串)

转载地址

1、用字符串分隔:

using System.Text.RegularExpressions;

string str="aaajsbbbjsccc";

string[] sArray=Regex.Split(str,"js",RegexOptions.IgnoreCase);

foreach (string i in sArray) Response.Write(i.ToString() + "<br>");

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

C#中Split分隔字符串的应用(C#、split、分隔、字符串)输出结果:

C#中Split分隔字符串的应用(C#、split、分隔、字符串)aaa

C#中Split分隔字符串的应用(C#、split、分隔、字符串)bbb

C#中Split分隔字符串的应用(C#、split、分隔、字符串)ccc

C#中Split分隔字符串的应用(C#、split、分隔、字符串) 

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

C#中Split分隔字符串的应用(C#、split、分隔、字符串)2、用多个字符来分隔:

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

string str="aaajbbbscccjdddseee";

string[] sArray=str.Split(new char[2]{'j','s'}); 

foreach(string i in sArray) Response.Write(i.ToString() + "<br>"); 

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

C#中Split分隔字符串的应用(C#、split、分隔、字符串)输出结果:

C#中Split分隔字符串的应用(C#、split、分隔、字符串)aaa

C#中Split分隔字符串的应用(C#、split、分隔、字符串)bbb

C#中Split分隔字符串的应用(C#、split、分隔、字符串)ccc

C#中Split分隔字符串的应用(C#、split、分隔、字符串)ddd

C#中Split分隔字符串的应用(C#、split、分隔、字符串)eee

C#中Split分隔字符串的应用(C#、split、分隔、字符串) 

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

C#中Split分隔字符串的应用(C#、split、分隔、字符串)3、用单个字符来分隔:

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

string str="aaajbbbjccc";

string[] sArray=str.Split('j');

foreach(string i in sArray) Response.Write(i.ToString() + "<br>");

C#中Split分隔字符串的应用(C#、split、分隔、字符串)

C#中Split分隔字符串的应用(C#、split、分隔、字符串)输出结果:

C#中Split分隔字符串的应用(C#、split、分隔、字符串)aaa

C#中Split分隔字符串的应用(C#、split、分隔、字符串)bbb

C#中Split分隔字符串的应用(C#、split、分隔、字符串)ccc

相关文章