Is Time by regex - CSharp System

CSharp examples for System:DateTime Time

Description

Is Time by regex

Demo Code


using System.Globalization;
using System.Text.RegularExpressions;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*from w ww .  j  a va2  s  .c  o  m*/

public class Main{
            public static bool IsTime(string timeval)
            {
                return Regex.IsMatch(timeval, @"^((([0-1]?[0-9])|(2[0-3])):([0-5]?[0-9])(:[0-5]?[0-9])?)$");
            }
}

Related Tutorials