2015-12-11 40 views
-6

如何匹配一個17位數字出現在字符串中的次數,然後使用它們?語言是C#/。NET我如何匹配基於字符串數量的東西?

+2

嘗試做前如果你不能發佈你嘗試的代碼,我們會幫你 –

+1

向我們展示一些你已經完成的代碼示例,這與Stack Overflow在提問時的策略不匹配。 – Chad

+0

我不熟悉'abunch'集合對象 – Plutonix

回答

0

你可以做一個簡單的正則表達式,但你確實應該讀一些MSDN文章試圖「用他們」

// Match a Regex and Do Stuff 
     public void showMatch(string input, string expr) 
     { 
      MatchCollection mc = Regex.Matches(input, expr); 
      int num = 0; 
      foreach (Match m in mc) 
      { 
       string tm = m.ToString(); 
       num++; 
       if (num == 1) 
       { 
        // Do Stuff if 1 match. 
       } 
       if (num == 2) 
       { 
        // Do Stuff if 2 matches. 
       } 
      } 
     } 


      // showMatch(input, @"(?:[0-9]+){17}"); 

MSDN Article

+0

我該如何使用? – CaptJamie

+0

nvm計算出來。 – CaptJamie

相關問題