博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
分割字符串
阅读量:5322 次
发布时间:2019-06-14

本文共 2807 字,大约阅读时间需要 9 分钟。

1   private void button1_Click(object sender, EventArgs e) 2         { 3             string aaaa = "NACA-1-4-0008"; 4             string[] indexlist = aaaa.Split('-'); 5         } 6  7         private void button2_Click(object sender, EventArgs e) 8         { 9             string str = "aaajSbbbjscccJS";10             string[] sArray = Regex.Split(str, "js", RegexOptions.IgnoreCase);11 12             string str1 = "technology";13             char[] separator = { 'o' };14             string[] arr = str1.Split(separator);15         }16 17         private void button3_Click(object sender, EventArgs e)18         {19             string str = "aaajbbbscccjdddseee";20             string[] sArray = str.Split(new char[2] { 'j', 's' });21         }22 23         string words = "1,2.3,,4";24         private void button4_Click(object sender, EventArgs e)25         {26             string[] split = words.Split(new Char[] { ',', '.' }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素27             string[] split1 = words.Split(new Char[] { ',', '.' }, 3, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 28             string[] split2 = words.Split(new Char[] { ',', '.' }, 4, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 29             string[] split3 = words.Split(new Char[] { ',', '.' }, 5, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 30             string[] split4 = words.Split(new Char[] { ',', '.' }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 31         }32 33         private void button5_Click(object sender, EventArgs e)34         {35             string[] split = words.Split(new string[] { ",", "." }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素36             string[] split1 = words.Split(new string[] { ",", "." }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素37         }38 39         private void button6_Click(object sender, EventArgs e)40         {41             string[] split = words.Split(new string[] { ",", "." }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素42             string[] split1 = words.Split(new string[] { ",", "." }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 43         }44 45         private void button7_Click(object sender, EventArgs e)46         {47             string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素48             string[] split1 = words.Split(new Char[] { ',', '.' }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素 49         }50 51 52         //需要注意的是没有重载函数public string[] Split(string[] separator),53         //所以我们不能像VB.NET那样使用words.Split(","),而只能使用words.Split(',')

 

转载于:https://www.cnblogs.com/luckxintao/p/5069982.html

你可能感兴趣的文章
自建数据源(RSO2)、及数据源增强
查看>>
2018icpc徐州OnlineA Hard to prepare
查看>>
使用命令创建数据库和表
查看>>
【转】redo与undo
查看>>
安卓当中的线程和每秒刷一次
查看>>
wpf样式绑定 行为绑定 事件关联 路由事件实例
查看>>
TCL:表格(xls)中写入数据
查看>>
Oracle事务
查看>>
String类中的equals方法总结(转载)
查看>>
标识符
查看>>
一步步教你轻松学奇异值分解SVD降维算法
查看>>
内存地址对齐
查看>>
创新课程管理系统数据库设计心得
查看>>
Could not resolve view with name '***' in servlet with name 'dispatcher'
查看>>
[转载] redis 的两种持久化方式及原理
查看>>
MyBaits学习
查看>>
管道,数据共享,进程池
查看>>
[Cypress] Stub a Post Request for Successful Form Submission with Cypress
查看>>
SDUTOJ3754_黑白棋(纯模拟)
查看>>
php中的isset和empty的用法区别
查看>>