匹配花括號內的內容
Input: {abc}, Output: abc
正則表達式: (?<=\{)[^}]*(?=\})
(?<=\{) 匹配以左花括號開頭
[^}]* 取得內容
(?=\}) 匹配以右花括號結束
private List<String> GetTokens(String str) { Regex regex = new Regex(@"(?<=\{)[^}]*(?=\})", RegexOptions.IgnoreCase); MatchCollection matches = regex.Matches(str); // Results include braces (undesirable) return matches.Cast<Match>().Select(m => m.Value).Distinct().ToList(); }