0

How to get all matches in a text

 string text={{string1}}{{string2}}{{string3}}{{string4}};

and returns

string1
string2
string3
string4
Opt Prutal
  • 384
  • 4
  • 14
  • What is a match in your case? What is the pattern for a match? – Mighty Badaboom Aug 21 '17 at 10:26
  • Using regex : string text= "{{string1}}{{string2}}{{string3}}{{string4}}"; string pattern = @"\{(?'text'[\w]+)"; MatchCollection matches = Regex.Matches(text, pattern); Console.WriteLine(string.Join(",",matches.Cast().Select(x => x.Groups["text"].Value).ToArray())); Console.ReadLine(); – jdweng Aug 21 '17 at 10:31

0 Answers0