title: php regular expression minimum and maximum length doesn't work as expected
body: <p>I want to create a regular expression in PHP, which will allow to user to enter a phone number in either of the formats below.</p>
  
  <p>345-234 898</p>
  
  <p>345 234-898</p>
  
  <p>235-123-456</p>
  
  <p>548 812 346</p>
  
  <p>The minimum length of number should be 7 and maximum length should be 12.</p>
  
  <p>The problem is that, the regular expression doesn't care about the minimum and maximum length. I don't know what is the problem in it. Please help me to solve it. Here is the regular expression.</p>
  
  <pre><code>if (preg_match("/^([0-9]+((\s?|-?)[0-9]+)*){7,12}$/", $string)) {
  echo "ok";
  } else {
  echo "not ok";
  }
  </code></pre>
  
  <p>Thanks for reading my question. I will wait for responses.</p>