Convert result of matches from regex into list of string

后端 未结 6 881
余生分开走
余生分开走 2020-12-14 15:22

How can I convert the list of match result from regex into List? I have this function but it always generate an exception,

6条回答
  •  感情败类
    2020-12-14 15:34

    With the Regex you have, you need to use Regex.Matches to get the final list of strings like you want:

    MatchCollection matchList = Regex.Matches(Content, Pattern);
    var list = matchList.Cast().Select(match => match.Value).ToList();
    

提交回复
热议问题