日期:2014-05-17 浏览次数:20979 次
string source = "01h:20m:12s";
Regex reg = new Regex(@"([\d]+)h:([\d]+)m:([\d]+)s");
Match mm = reg.Match(source);
MessageBox.Show(mm.Groups[1].Value+"小时"+mm.Groups[2].Value+"分"+mm.Groups[3].Value+"秒");
String time = "01h:20m:12s";
int length = time.Length;
int h = int.Parse(time.Substring(0, time.IndexOf("h:")));
int m = int.Parse(time.Substring(time.IndexOf("h:")+2, time.IndexOf("m:") - time.IndexOf("h:")-2));
int s = int.Parse(time.Substring(time.IndexOf("m:")+2, time.IndexOf("s") - time.IndexOf("m:")-2));
int newTime = h * 60 * 60 + m * 60 + s;//这就是最终的秒数
string source = "01h:20m:12s";
Regex reg = new Regex(@"([\d]+)h:([\d]+)m:([\d]+)s");
Match mm = reg.Match(source);
MessageBox.Show((int.Parse(mm.Groups[1].Value) * 3600 + int.Parse(mm.Groups[2].Value) * 60 + int.Parse(mm.Groups[3].Value)).ToString() + "秒");