C#的时间正则表达式 不指定

Else , 2008/06/26 11:40 , 代码片段,演示也有 , Comments(0) , Reads(4993) , Via Original
[codes=C#]
///
public string timeformat(string timestr)
        {

            timestr = timestr.Trim();


            if (Regex.IsMatch(timestr, @"^(\d{4})\D*(\d{2})\D*(\d{2})$"))
            {
            
          
                //this.Nodate = true;
                return Regex.Replace(timestr, @"^(\d{4})\D*(\d{2})\D*(\d{2})$", "$1-$2-$3", RegexOptions.None);
                
            }
            
            else
            {
               // this.Nodate = false;
                return timestr;
              

            }

        }[/codes]
Tags: ,
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]