1            string strText = "中国河北省石家庄市";
 2            // 要使用key的功能,需要这样写?<prov>("?"必须加),"prov"为key名称
 3            Regex oRegex = new Regex(@"(中国)*(?<prov>.+省)(?<city>.+市)");
 4
 5            MatchCollection oMatchCollection = oRegex.Matches(strText);
 6
 7            foreach (Match oMatch in oMatchCollection)
 8            {
 9                // 取值的时候就用正则表达式里的key取值
10                MessageBox.Show(oMatch.Groups["prov"+ "----" + oMatch.Groups["city"]);
11            }
 
很好用!强力推荐!

what the hell is going on ??!!