How can I put Regex.Matches into an array?

后端 未结 4 1767
花落未央
花落未央 2020-12-10 12:54

I have multiple Regex Matches. How can I put them into an array and call them each individually, for example ID[0] ID[1]?

string value = (\"{\\\         


        
4条回答
  •  独厮守ぢ
    2020-12-10 12:57

    another method

      string value = ("{\"ID\":\"([A-Za-z0-9_., ]+)\",");
      MatchCollection match = Regex.Matches(textt, @value);
    
      string[] ID = new string[match.Count];
      for (int i = 0; i < match.Length; i++)
      {
        ID[i] = match[i].Groups[1].Value; // (Index 1 is the first group)
      }
    

提交回复
热议问题