Friday, March 24, 2023

RegEx to check if a string is in YYYY-MM-DD in dynamics 365

using System.Text.RegularExpressions;

class ITSRegEx_AY

{

    public static boolean validateDateString(str dateString)

    {

        str pattern = @"^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$";

        Regex regex = new Regex(pattern);

        Match match = regex.Match(dateString);


        return match.Success;

    }


}