- 最後登錄
- 2024-3-29
- 在線時間
- 0 小時
- 註冊時間
- 2016-8-22
- 閱讀權限
- 20
- 精華
- 0
- UID
- 16624936
- 帖子
- 61
- 積分
- 49 點
- 潛水值
- 26590 米
| 發表於 2016-12-27 10:13 AM|顯示全部樓層 如果瀏覽伊莉時速度太慢或無法連接,可以使用其他分流瀏覽伊莉,www01.eyny.com(02,03)。 也可以用一個類別來放資料- class Nums
- {
- public string N1 { get; set; }
- public string N2 { get; set; }
- public string N3 { get; set; }
- }
複製代碼 主程式- String str = @"
- 1 1 m2-10gb-xp-xfp up up
- 2 m20-1gb-xp-sfp up up
- 2 1 m20-1gb-xp-sfp up up
- 3 1 m20-1gb-xp-sfp up up
- 2 m20-1gb-xp-sfp up up
- 4 1 p6-10g-sfp up up
- 2 p6-10g-sfp up up
- 5 1 m2-10gb-xp-xfp up up
- 2 m20-1gb-xp-sfp up up
- 6 1 m1-10gb-xp-xfp up up
- 2 m20-1gb-xp-sfp up up
- 7 1 m20-1gb-xp-sfp up up
- 8 1 m20-1gb-xp-sfp up up
- 2 m20-1gb-xp-sfp up up
- 10 1 imm5-10gb-xp-xfp up up";
- string tempStr = string.Empty;
- List<Nums> list = new List<Nums>();
- string[] lines = str.Replace("up","").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
- foreach (string line in lines)
- {
- MatchCollection strMatch = Regex.Matches(line, @"\d{1,2}(?= |-)");
- Nums nums = new Nums();
- if (strMatch.Count == 3)
- {
- tempStr = strMatch[0].Value;
- nums.N1 = strMatch[0].Value;
- nums.N2 = strMatch[1].Value;
- nums.N3 = strMatch[2].Value;
- }
- else if (strMatch.Count == 2)
- {
- nums.N1 = tempStr;
- nums.N2 = strMatch[0].Value;
- nums.N3 = strMatch[1].Value;
- }
- list.Add(nums);
- }
- foreach (var num in list)
- {
- Console.WriteLine("{0}/{1}/{2}", num.N1, num.N2, num.N3);
- }
複製代碼 ... |
|