title: Php preg_match pattern
body: <p>I have a form field that I want to check if the user submitted a correct pattern. I tried it this way.</p>
  
  <pre><code>// $car_plate should in XXX-1111, or XXX-111(three letters in uppercase followed by a dash and four or three numbers)
  &lt;?php
      $car_plate = $values['car_plate'];
      if (!preg_match('[A-Z]{3}-[0-9]{3|4}$', $car_plate)) {
          $this-&gt;errors ="Pattern for plate number is XXX-1111 or XXX-111";
      } else {
          // code to submit
      }
  ?&gt;
  </code></pre>
  
  <p>The following car_plate numbers is in correct format (AAA-456, AGC-4567, WER-123). In this case it always return the error. What is the correct way?</p>