日期:2014-05-18 浏览次数:21046 次
string s = "[Font: Name=宋体, Size=9, Units=3, GdiCharSet=1, GdiVerticalFont=False]"; System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match(s, @"^\[Font\: Name\=(?<name>[^,]+), Size=(?<size>\d+), Units=(?<units>\d+), " + @"GdiCharSet=(?<charSet>\d+), GdiVerticalFont=(?<verticalFont>\w+)\]"); //Console.WriteLine(match.Result("${name}")); //测试代码 //Console.WriteLine(match.Result("${size}")); //Console.WriteLine(match.Result("${units}")); //Console.WriteLine(match.Result("${charSet}")); //Console.WriteLine(match.Result("${verticalFont}")); Font FONT = new Font(match.Result("${name}"), float.Parse(match.Result("${size}")), FontStyle.Regular, (GraphicsUnit)int.Parse(match.Result("${units}")), byte.Parse(match.Result("${charSet}")), bool.Parse(match.Result("${verticalFont}")));