日期:2014-05-17 浏览次数:21172 次
string str = "广州:20深圳:755肇庆:758湛江:759";
string CityName = "广州";
var list = Regex.Matches(str, string.Format(@"(?<={0}:)\d+", CityName)).OfType<Match>().Select(t => t.Value).ToList();
string s = "广州:20深圳:755肇庆:758湛江:759";
Dictionary<string, string> dictionary = Regex.Matches(s, @"(?<city>[^:]+):(?<value>\d+)").Cast<Match>().ToDictionary(k => k.Groups["city"].Value, v => v.Groups["value"].Value);
Console.WriteLine(dictionary["深圳"]); //输出“深圳”的值