Custom field format validation without being mandatory

How can I setup a custom field validation and have if so that it can be
blank, OR match my regular expression

Currently I have: (?#YYYY-MM-DD HH:mm:ss)^[12]\d{3}-\d{2}-\d{2}
\d{2}:\d{2}:\d{2}$

Really what I guess what I think I’m looking for is
/(^[12]\d{3}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$|^$)/

 How can I setup a custom field validation and have if so that it can be blank, OR match my
 regular expression
 Currently I have: (?#YYYY-MM-DD HH:mm:ss)^[12]\d{3}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$
 Really what I guess what I think I'm looking for is /(^[12]\d{3}-\d{2}-\d{2}
 \d{2}:\d{2}:\d{2}$|^$)/

perldoc perlre will tell you more than you ever wanted to know, but
something like:
/^(?:foo|)$/ or /^foo$|^$/
is what you want to emulate.

Remember that the (?#YYYY-MM…) part needs to be self contained since
it isn’t an active part of the regex.

-kevin