如何使用正则表达式C#在句子中出现{{something}}的所有内容

时间:2014-04-10 08:20:58

标签: c# .net regex

我有像

这样的信号
  

您好{{Bla bla}}我的名字是{{other bla}}

我希望使用正则表达式

{{ somthing }}全部出现

我该怎么办? 感谢

1 个答案:

答案 0 :(得分:0)

string input = "Hello {{Bla bla }} my name is {{other bla}}";
var matches = Regex.Matches(input, @"\{\{(.+?)\}\}").Cast<Match>()
              .Select(m => m.Groups[1].Value)
              .ToList();