Get values between curly braces c#

Use Matches of Regex rather than Split to accomplish this easily:

string input = "{name}{[email protected]}";
var regex = new Regex("{(.*?)}");
var matches = regex.Matches(input);
foreach (Match match in matches) //you can loop through your matches like this
{
  var valueWithoutBrackets = match.Groups[1].Value; // name, [email protected]
  var valueWithBrackets = match.Value; // {name}, {[email protected]}
}

Leave a Comment