string str1="xuejiehome.com,<a href=\"http://www.xuejiehome.com\" target=\"_blank\">www.xuejiehome.com</a>,ask.xuejiehome.com";
string [] str=str1.split(','); //得到一个str的数组{"xuejiehome.com","www.xuejiehome.com","ask.xuejiehome.com"}
foreach(string s in str)
{
Response.Write(s+"<br />");
}
//输出结果:
// xuejiehome.com
// <a href=\"http://www.xuejiehome.com\" target=\"_blank\">www.xuejiehome.com</a>
// ask.xuejiehome.com
string str2="1,2,3,4.5.6.7";
string strM=str2.Split(new char[2]{',','.'});
foreach(string var in strM){
Response.Write(var + "<br />");
}
//输出结果:
//1
//2
//3
//4
//5
//6
//7
string str2 = "1,2,3,4.5.6.7";
string[] strM = str2.Split(new string[] { ",", "." }, StringSplitOptions.RemoveEmptyEntries);
}
string str3="helloMrZhanghelloMissLihelloMrZhao";
string[] strName= System.Text.RegularExpressions.Regex.Split(str3,"hello",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach(string var in strName)
{
Response.Write(var+"<br />");
}
//结果
//MrZhang
//MissLi
//MrZhao| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |