C#分割字符串的几种方法
2013-06-06 14:45
225 查看
单个字符分割
string s="abcdeabcdeabcde";
string[] sArray=s.Split('c');
foreach(string i in sArray)
Console.WriteLine(i.ToString());
输出下面的结果:
ab
deab
deab
de
多个字符分割
string s="abcdeabcdeabcde
string[] sArray1=s.Split(new char[3]{'c','d','e'});
foreach(string i in sArray1)
Console.WriteLine(i.ToString());
可以输出下面的结果:
ab
ab
ab
多个字符分割(正则表达式)
string content="agcsmallmacsmallgggsmallytx";
string[]resultString=Regex.Split(content,"small",RegexOptions.IgnoreCase)
foreach(string i in resultString)
Console.WriteLine(i.ToString());
输出下面的结果:agc
mac
ggg
ytx
string s="abcdeabcdeabcde";
string[] sArray=s.Split('c');
foreach(string i in sArray)
Console.WriteLine(i.ToString());
输出下面的结果:
ab
deab
deab
de
多个字符分割
string s="abcdeabcdeabcde
string[] sArray1=s.Split(new char[3]{'c','d','e'});
foreach(string i in sArray1)
Console.WriteLine(i.ToString());
可以输出下面的结果:
ab
ab
ab
多个字符分割(正则表达式)
string content="agcsmallmacsmallgggsmallytx";
string[]resultString=Regex.Split(content,"small",RegexOptions.IgnoreCase)
foreach(string i in resultString)
Console.WriteLine(i.ToString());
输出下面的结果:agc
mac
ggg
ytx
相关文章推荐
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中Split等分割字符串的几种方法(转)
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中Split等分割字符串的几种方法
- c#中Split等分割字符串的几种方法(转)
- c#中分割字符串的几种方法
- [转]c#中Split等分割字符串的几种方法
- asp.net(c#)中分割字符串的几种方法
- 【转载】c#中分割字符串的几种方法
- c#中Split等分割字符串的几种方法(转)
- c#中Split等分割字符串的几种方法
- C#中使用split分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法
- c#中分割字符串的几种方法