日期:2014-05-18 浏览次数:20435 次
string str="2008-07-20多云26℃~33℃微风2008-07-21阵雨转多云26℃~34℃微风2008-07-22雷阵雨转多云26℃~34℃微风"; System.Text.RegularExpressions.Regex reg=new System.Text.RegularExpressions.Regex("(?<Date>[0-9-]{1,})(?<Weather>[\u4e00-\u9fa5]{1,})(?<Temperature>[0-9-℃~]{1,})(?<Wind>[\u4e00-\u9fa5]{1,})",System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.MatchCollection m = reg.Matches(str); //设定要查找的字符串 string newstr="当前天气:"+ m[0].Groups["Weather"].ToString() + m[0].Groups["Temperature"].ToString()+m[0].Groups["Wind"].ToString()+" 明日天气:"+ m[1].Groups["Weather"].ToString() + m[1].Groups["Temperature"].ToString()+m[1].Groups["Wind"].ToString()+" 后日天气:"+ m[2].Groups["Weather"].ToString() + m[2].Groups["Temperature"].ToString()+m[2].Groups["Wind"].ToString(); Response.Write(newstr);