fork download
  1. <?php
  2.  
  3. $re = "/\A[(]?[0-9]{3}[)]?[ ,-]?[0-9]{3}[ ,-]?[0-9]{4}\z/";
  4. $str = "909-999-9999";
  5. if (preg_match($re, $str, $m)) {
  6. echo "MATCHED!";
  7. }
Success #stdin #stdout 0.04s 52480KB
stdin
Standard input is empty
stdout
MATCHED!