fork download
  1. <?php
  2. $numbers = array("a421zx", "asfqe", "l228ol");
  3.  
  4. $matches = array();
  5.  
  6. $regexp = '/^[a-z][0-9]{3}[a-z]{2}$/';
  7.  
  8. foreach ($numbers as $number){
  9. if (preg_match($regexp, $number, $matches)) {
  10. echo "All right:\n";
  11. echo "$number\n";
  12. echo "---------------\n";
  13. } else {
  14. echo "Uncorrectly. Please, kill yorself:\n";
  15. echo "$number\n";
  16. echo "---------------\n";
  17. }
  18. }
  19.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
All right:
a421zx
---------------
Uncorrectly. Please, kill yorself:
asfqe
---------------
All right:
l228ol
---------------