设问是说明方法吗:介绍asp.net正则表达式的组集合-程序开发-红黑联盟

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 15:29:47

介绍asp.net正则表达式的组集合
 
 
文章录入:7747.Net    责任编辑:7747.Net  11 
 【字体:小 大】
 
简单实例:
string s = "2010-7-22";
Regex reg = new Regex(@"(?\d{4})-(?\d{1,2})-(?\d{1,2})",RegexOptions.Compiled);
    
Match match = reg.Match(s);
int year =  int.Parse(match.Groups["y"].Value);
int month = int.Parse(match.Groups["m"].Value);
int day = int .Parse(match.Groups["d"].Value);
DateTime time = new DateTime(year,month,day);
 

摘自红色黑客联盟(www.7747.net) 原文:http://www.7747.net/kf/201009/73938.html