title: Regex validation for North American phone numbers
body: <p>I am having trouble finding a pattern that would detect the following </p>
  
  <p>909-999-9999 </p>
  
  <p>909 999 9999</p>
  
  <p>(909) 999-9999</p>
  
  <p>(909) 999 9999</p>
  
  <p>999 999 9999 </p>
  
  <p>9999999999</p>
  
  <pre><code>\A[(]?[0-9]{3}[)]?[ ,-][0-9]{3}[ ,-][0-9]{3}\z
  </code></pre>
  
  <p>I tried it but it doesn't work for all the instances . I was thinking I can divide the problem by putting each character into an array and then checking it. but then the code would be too long. </p>