Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation of a date with a given format in Matlab

I am designing a GUI. I have an edit text box where I enter a date string with the following format '31 Mar 2011 10:00:00.000'. I need code to validate it and write an error message in case of invalid input. Thank you for your attention. Cheers.

like image 344
julianfperez Avatar asked Dec 22 '22 15:12

julianfperez


1 Answers

Could you handle this with a regular expression. If you will require your user to input a date with a specific format, I could see parsing this string with the matlab function regexp to see if it matches a given format. In the case you gave above something like

s='31 Mar 2011 10:00:00.000'
regexp(s,'\d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2}\.?\d*')

could be used to see if your date matches the format.

like image 79
Memphis Avatar answered Feb 16 '23 14:02

Memphis