C#中Split分隔字符串的应用
2006-12-15 01:17
309 查看
学习中总结了几种分隔字符串的方法:
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>");
输出结果:
aaa
bbb
ccc
2、用多个字符来分隔:string str="aaajbbbscccjdddseee";string[] sArray=str.Split(new char[2]{'j','s'}); foreach(string i in sArray) Response.Write(i.ToString() + "<br>");
输出结果:
aaa
bbb
ccc
ddd
eee
3、用单个字符来分隔:string str="aaajbbbjccc";string[] sArray=str.Split('j');foreach(string i in sArray) Response.Write(i.ToString() + "<br>");
输出结果:
aaa
bbb
ccc
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>");
输出结果:
aaa
bbb
ccc
2、用多个字符来分隔:string str="aaajbbbscccjdddseee";string[] sArray=str.Split(new char[2]{'j','s'}); foreach(string i in sArray) Response.Write(i.ToString() + "<br>");
输出结果:
aaa
bbb
ccc
ddd
eee
3、用单个字符来分隔:string str="aaajbbbjccc";string[] sArray=str.Split('j');foreach(string i in sArray) Response.Write(i.ToString() + "<br>");
输出结果:
aaa
bbb
ccc
相关文章推荐
- C#中Split分隔字符串的应用
- C#中Split分隔字符串的应用
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C# Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C# 之Split分隔字符串的应用
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- C#2005中Split分隔字符串的应用(C#、split、分隔、字符串)