title: date validation regex - make leading zeroes optional
body: <p>I currently use the following regex from <a href="http://regexlib.com" rel="nofollow noreferrer">http://regexlib.com</a> to validate the incoming date using the pattern YYYY-MM-DD. But the leading zeroes are mandatory and I want it to be optional.</p>
  
  <pre><code>((((1[26]|2[048])00)|[12]\d([2468][048]|[13579][26]|0[48]))-((((0[13578]|1[02])-(0[1-9]|[12]\d|3[01]))|((0[469]|11)-(0[1-9]|[12]\d|30)))|(02-(0[1-9]|[12]\d))))|((([12]\d([02468][1235679]|[13579][01345789]))|((1[1345789]|2[1235679])00))-((((0[13578]|1[02])-(0[1-9]|[12]\d|3[01]))|((0[469]|11)-(0[1-9]|[12]\d|30)))|(02-(0[1-9]|1\d|2[0-8]))))
  </code></pre>
  
  <p><img src="https://www.debuggex.com/i/lDaR_Qg3LemyQ-S7.png" alt="Regular expression visualization"></p>
  
  <p><a href="https://www.debuggex.com/r/lDaR_Qg3LemyQ-S7" rel="nofollow noreferrer">Debuggex Demo</a></p>
  
  <p><strong><a href="https://regex101.com/r/cr4wax/1" rel="nofollow noreferrer">Test case</a></strong></p>
  
  <pre><code>2000-01-01
  2000-1-1
  2000-01-1
  2000-1-01
  </code></pre>
  
  <p>are all valid. But only the first test case is accepted, as of now.</p>
  
  <p>Can you please help?</p>