How can I write a regex for MM:DD:YYYY:HH:MM:SS?
It depends whether you want to check are all characters divided by :
numbers or you also want to check whether you will not get totaly improper data like the 32nd of December or the hour like 25:66. To have such a basic validation you should use a little more complex regexp than the one provided by @Pascal MARTIN, e.g.,
[0-1][0-9]:[0-3][0-9]:[1-2][0-9]{3}:[0-2][0-9]:[0-5][0-9]:[0-5][0-9]
If you want to capture the values for month, year, ... you could use something like this, I suppose :
([0-9]{2}):([0-9]{2}):([0-9]{4}):([0-9]{2}):([0-9]{2}):([0-9]{2})
If supported by your regex engine, \d
can be used as an alias to [0-9]
:
(\d{2}):(\d{2}):(\d{4}):(\d{2}):(\d{2}):(\d{2})