text: Q:
  
  Regex expression to search upto nested level
  
  How to search search string upto nested level using Regex expression
  Like say: I have string like 
  var str = "samir patel {samirpatel@test1.com{sam@somedomain.com}}";
  
  Out put should be sam@somedomain.com
  
  A:
  
  You could simply use this pattern:
  {([^{}]*)}
  
  This will match any string like {some content} which does not contain any other group like {some content}. You can test this here.
  You can capture this using:
  var str = "samir patel {samirpatel@test1.com{sam@somedomain.com}}";
  var regex = new Regex("{([^{}]*)}");
  var matches = regex.Matches(str);
  var output = matches[0].Groups[1].Value;
  // output == "sam@somedomain.com"
  
  Or more simply:
  var str = "samir patel {samirpatel@test1.com{sam@somedomain.com}}";
  var output = Regex.Match(str, "{([^{}]*)}").Groups[1].Value; 
  // output == "sam@somedomain.com"
  
  