Find each RegEx match in string

后端 未结 3 1854
南旧
南旧 2020-12-18 19:44

id like to do something like

foreach (Match match in regex)
    {
    MessageBox.Show(match.ToString());
    }

Thanks for any help...!

3条回答
  •  执笔经年
    2020-12-18 19:57

    from MSDN

      string pattern = @"\b\w+es\b";    
      Regex rgx = new Regex(pattern);    
      string sentence = "Who writes these notes?";
    
      foreach (Match match in rgx.Matches(sentence))
      {
    
         Console.WriteLine("Found '{0}' at position {1}", 
                           match.Value, match.Index);
      }
    

提交回复
热议问题