c# - Regular expression get string between curly braces -


I want to ask about regular expressions in C #.

I have a string: Ex: "Welcome to {{stackoverflow}. It is a question of C #}"

{} Regarding regular expression to get content between Any ideas in I want to get 2 strings: "Welcome to Scareoverflow. It's a question C #" and "StackWarflow".

Thank you in advance and sorry for my English.

Hi how would this not be with a regular expression, but it would be easy to add a little recursion:

  using the system; Using System.Collections.Generic; Using System.Text.RegularExpressions; Static Class Program (Static Zero Main () {string test = "Welcome to {{StackHowarflow}}. This is a question C #}"; // Whatever is not 'Between Brakes' {'}, Non Greedy Regex regex = New Regex ("{([^ {] *?)}", RegexOptions.Compiled); // content list & lt; String & gt; Content = new list & lt; String & gt; (); // Flag to determine whether we found matches in the open matches; Found = false; // Start the most interesting match, and replace them with your content, braces {matchesFound = false; // Replace with a MatchEvaluator which adds content to our // list. Test = regex.Replace (test, (match) => {matchesFound = true; var replacement = match.Groups [1] Value; content; add (replacement); returning place;}); } While (matches found); Foreach (various materials in content) {Console.WriteLine (content); }}}    

Comments