string[] myagent = agentinfo.split(new string[] { $#$ }, stringsplitoptions.none);
if (myagent.length == 3)
{
this.qlookupmyagent.text = myagent[0].tostring();
this.qcalenderstartdate.value = myagent[1].tostring();
this.qcalenderenddate.value = myagent[2].tostring();
}
vs2003下用下面的方法:
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
以上就是字符串分割的使用实例代码的详细内容。
