按照指定的字符分割字符串形成字符数组
2012-02-22 09:25
441 查看
using System; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string str = "ab,cd,ef|12*34"; string[] strs = str.Split(',','|','*');// 按照指定的字符分割字符串形成字符数组 foreach (string c in strs) { Console.WriteLine("|{0}|", c); } Console.WriteLine("-----------------------------"); string str2 = "ab,cd,,ef|12*34"; string[] strs2 = str2.Split(',', '|', '*');// 无法去处空白(有空格不算)字符串 foreach (string c in strs2) { Console.WriteLine("|{0}|", c); } Console.WriteLine("-----------------------------"); string str3 = "ab,cd,,ef|12*34"; string[] strs3 = str3.Split(new char[] { ',', '|', '*' }, StringSplitOptions.RemoveEmptyEntries);// 去处空白(有空格不算字符串 foreach (string c in strs3) { Console.WriteLine("|{0}|", c); } Console.ReadKey(); } } }
相关文章推荐
- 按照指定的字符串分割字符串形成字符数组
- SQL分割字符串,SQL按照指定字符分割字符串,SQL处理字符串...
- SQL分割字符串,SQL按照指定字符分割字符串,SQL处理字符串...
- C#下按照指定字符进行字符串分割
- 按照指定字符(@split )分割字符串,并取第@index 个
- 将字符串按照指定的长度进行分割(一个中文视为两个字符)
- SQL分割字符串,SQL按照指定字符分割字符串,SQL处理字符串...
- 正确使用字节流按照指定字符编码获取字符串
- 删除字符串中指定的字符形成字符串
- 字符串分割为字符串数组 去除前后指定字符
- [C语言]字符串处理 - 以指定的字符串分割字符串(支持中文字符)
- python按照多个字符对字符串进行分割的方法
- 自己实现的一个字符串分割截取函数,以及查找指定字符
- oracle怎么切割一个指定的字符串按指定的标志符分割成字符数组
- mysql字符串根据指定字符分割
- Java 将字符串按照指定字符拆分 为List
- [C语言]字符串处理 - 以指定的字符串分割字符串(支持中文字符)
- iOS NSString字符串按照特定字符分割成数组
- php实现将字符串按照指定距离进行分割的方法
- php把字符串指定字符分割成数组