作者liptonbin (wind)
看板C_Sharp
標題[問題] 請問split問題
時間Tue Sep 4 17:00:59 2007
請問我在c#上面要分割 如41 99 311 16
50 99 300 100
52 10 11 20
...
這四個數字
string[] words1 = Regex.Split(str,@"\s+");
textBox1.Text = words1[0];
textBox2.Text = words1[1];
textBox3.Text = words1[2];
textBox4.Text = words1[3];
經過以上可能變成
textBox1.Text = words1[0]=>41
textBox2.Text = words1[1]=>99
textBox3.Text = words1[2]=>311
textBox4.Text = words1[3];
但是有時候換另外一行又可以
請問為什麼有時候會缺一個
我的regex.split有少寫什麼嗎?(空格可能有tab鍵或空格+tab鍵等)
謝謝喔
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.69.149.252
→ bcse:少了 \r 或 \n 嗎? 09/04 20:01
→ liptonbin:我用@"[\s\r\t]+" 還是不行 09/04 21:47