//定義正則表達式,解析得到 [ 與 ] 之間的內容,內容包括 [ 和 ]
//要注意這個 .*? 的寫法, 附加的問號是表示盡可能短匹配,這很重要,否則返回最長匹配
string patttern = @"([).*?(])";
//要注意這個 .*? 的寫法, 附加的問號是表示盡可能短匹配,這很重要,否則返回最長匹配
string patttern = @"([).*?(])";
//解析得到 [ 與 ] 之間內容,保存在 match 中
Match match = Regex.Match(jsonString, patttern, RegexOptions.IgnoreCase);
Match match = Regex.Match(jsonString, patttern, RegexOptions.IgnoreCase);
//解析得到多個 [ 與 ] 之間內容,保存在 matches 中
List<string> lst = new List<string>();
MatchCollection matches = Regex.Matches(jsonString, patttern, RegexOptions.IgnoreCase);
foreach (Match m in matches)
{
lst.Add(m.Value);
}
List<string> lst = new List<string>();
MatchCollection matches = Regex.Matches(jsonString, patttern, RegexOptions.IgnoreCase);
foreach (Match m in matches)
{
lst.Add(m.Value);
}