I am trying to validate a text string as a date before processing it, however both of the regex i have tried are throwing syntax errors and I can't see why. From what I can tell there is nothing wrong with either. These are the strings:
var datePattern1 = new RegExp( (0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])[-](19|20)\d\d );
and
var datePattern2 = new RegExp( [0-3][0-9]-(0|1)[0-9]-(19|20)[0-9]{2} );
Appreciate any help.