日期:2014-05-18  浏览次数:20912 次

split问题
有一串动态的字符串:> |ABC1|3; <|ABC2|4; <|ABC3|2:...> |ABCn|m
|ABC|为固定的字符,n是标记第几个的,m是自己输入的数字
需要输出成为   |ABC1|> 3   |ABC2| <4   ...|ABCn|> m

------解决方案--------------------
var aa=new Array();
aa=字符串.split( "; ");
aa=aa.replace( "| ", "|> ")


------解决方案--------------------
转化下:只需要将每个;前后的两个字符index交换下,然后去掉;和|
------解决方案--------------------
string s= "> ABC1 ";
Regex re=new Regex(@ "(> )(\w+)(\d) ");
re.Replace(s,re.Match(s).value, "$3 "+ "$2 "+ "$1 ");
------解决方案--------------------
string s= "> abc3 ";
Regex re = new Regex(@ "(> )(\w+)(\d) ");
s=re.Replace(s, "$2 "+ "$1 "+ "$3 ");

------解决方案--------------------
string[] s=字符串.split( "; ");

string[] ss = s[0].split( "| ");
string sss = "| " + ss[1] + "| " + ss[0] + ss[2];
------解决方案--------------------
s[i] 循环
------解决方案--------------------
string[] s=字符串.split( "; ");
string sss= " ";
for(int i=0;i <s.Length;i++)
{
string[] ss = s[0].split( "| ");
sss += ss[1] + ss[0] + ss[2]+ " ";
}