日期:2014-05-19  浏览次数:20455 次

[谢谢]split怎么样用呢??比如:
string   x= "tttt <repeter> tttt <repeter> tttt <repeter> tttt "

我现在要以 <repeter> 分割x

怎么写呢??

------解决方案--------------------
string[] target_arr = x.Split( " <repeter> ");
------解决方案--------------------
vb.net写法,希望对你有帮助
Dim strNames() As String
Dim strName2 As String = TextBox1.Text.ToString
strNames = strName2.Split(New Char() { "( ", ") "})
------解决方案--------------------
ding
------解决方案--------------------
split好像只能分割char型的

------解决方案--------------------
例如:
string x= "tttt*tttt*tttt*tttt "

string[] target_arr = x.Split( "* ");

------解决方案--------------------
这种不算是技术问题;
楼主应该去msdn library上找split的用法及说明,这样才会提升自己
别人给的代码你看了只知道怎么用,但具体实现原理及更高级的用法你是一下子不会知道的
------解决方案--------------------
string x = "tttt <repeter> tttt <repeter> tttt <repeter> tttt ";
string ss=null;
string[] xx = System.Text.RegularExpressions.Regex.Split(x, " <repeter> ");
foreach(string s in xx)
{
ss += s+ " <br/> ";
}
Label1.Text = ss;
------解决方案--------------------
x = x.Replace( " <repeter> ", "* ");


string[] target_arr = x.Split( "* ");
------解决方案--------------------
string x = "tttt <repeter> tttt <repeter> tttt <repeter> tttt ";
string ss=null;
string[] xx = System.Text.RegularExpressions.Regex.Split(x, " <repeter> ");
foreach(string s in xx)
{
ss += s+ " <br/> ";
}
Label1.Text = ss;
________________________________________

正解
------解决方案--------------------
string x = "000 <repeter> 1111 <repeter> 2222 <repeter> 3333 ";
string strS = null;
string[] strArray = System.Text.RegularExpressions.Regex.Split(x, " <repeter> ");
foreach (string strA in strArray)
{
strS += strA + " <br/> ";
}
Response.Write(strS);
测试通过!