你贴的是全角。Regex re = new Regex("(?<=\\()(?<key>[^\\(,]+),(?<value>[^\\),]+)(?=\\))"); MatchCollection mc = re.Matches("(121.2,22.3)(121.23,22.5)(121.2,21.0)(122.1,21)"); foreach (Match ma in mc) { Console.WriteLine("{0}:{1}", ma.Groups["key"], ma.Groups["value"]); }
MatchCollection mc = re.Matches("(121.2,22.3)(121.23,22.5)(121.2,21.0)(122.1,21)");
foreach (Match ma in mc)
{
Console.WriteLine("{0}:{1}", ma.Groups["key"], ma.Groups["value"]);
}
void Main()
{
string str=@"(121.2,22.3)(121.23,22.5)(121.2,21.0)(122.1,21)"; foreach(Match m in Regex.Matches(str,"[((]([^,]+),([^))]+)[))]"))
{
Console.WriteLine(string.Format("{0}\t{1}",m.Groups[1].Value,m.Groups[2].Value));
}
}/*
121.2 22.3
121.23 22.5
121.2 21.0
122.1 21
*/