您的位置:程序门 -> .net技术 -> c#



字符串分割问题。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


字符串分割问题。
发表于:2008-01-23 22:16:33 楼主
“       c1           chip-135                   6.54             79.25           0                     t                 chip-135     ”

面对怎样的字符串,应该怎样分割呢?
发表于:2008-01-23 22:32:191楼 得分:0
你可以使用   string.split   method   (char[],   stringsplitoptions)   方法,譬如

string   yourstring   =   ".............";
string[]   ss   =   yourstring.split(new   char[]{'   ','\t'},stringsplitoptions.removeemptyentries);

或者使用
string[]   ss   =   system.text.regularexpressions.regex.split   (yourstring,@"\s+");
发表于:2008-01-23 22:36:502楼 得分:0
c# code
using system; public class program { public static void main() { string source = " c1 chip-135 6.54 79.25 0 t chip-135 "; string[] result = source.split(new char[] { ' ' }, stringsplitoptions.removeemptyentries); foreachstring s in result) console.writeline(s); console.read(); } }




快速检索

最新资讯
热门点击