I am currently in the process of creating a regular expression that can match 0 to 9 (up to 10 digits) and /-. (0 to 2 max), without having to be all . or all //. It can be /.\- or .-. or any combination of the three, with a maximum of two of those characters.
My goal is to verify if a date is in specified formats. The user has the option to input 1 or 10.02, etc. I will separate that value and utilize it later on.
How can I construct the regex for this? The task is being carried out in Javascript.
I attempted var pattern =/^([0-9([\/.-]{0,2})]{1,10})$/g; before ultimately giving up.
Edit:
1 -> true
10.10 - true
10.12/2020 - true
/ -> false
.10.20 - false