title: Regular Expression to validate xx-xxxxxxx or xxx-xx-xxxx
body: <p>I am trying to build a single regular expression validator that will only acccept values in the following formats:-</p>
  
  <p>string1 = xxx-xx-xxxx</p>
  
  <p>or </p>
  
  <p>string1 = xx-xxxxxxx </p>
  
  <p>How can I make the regex accept both kinds of values for the same element?</p>
  
  <p>The x's represent numbers only.</p>
  
  <p>so total number of digits = 9 (anything between 0-9)</p>
  
  <p>total number of elements in the value is either 11 or 10... depending on which format.</p>
  
  <p>and total number of dashes is either 2 or 1.</p>
  
  <p>How can I write this into a regular expression? Can anyone point me towards the right direction :- article/website.</p>
  
  <p>I do have some knowledge on regular expressions, where i can verify phone numbers and dates and such. So a little help will go a long way. Thank you.</p>