I'm trying to write a regular expression that validates both `dd-mm-yyyy` and `dd-mm-yyyy hh:mm:ss` at the same time. 

For example, 
`28-02-2018` and `28-02-2018 03:30:55` should be validated correctly by a single regex. 

I created two separated regex so far, one for the date and the other one for time and I do not understand how to combine of these so that it'll work for both the cases. 

dd-mm-yyyy, dd/mm/yyyy, dd.mm.yyyy -

```
^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.]([12][0-9]\d\d)$

```

hh:mm:ss -

```
^(0?[0-9]|1[0-9]|2[0-3])[\:]([0-5][0-9])[\:]([0-5][0-9])$

```

I handled incorrect day and month numbers. Leap years are not a problem for me. 

How would I do it?