PHP : expressions regulieres les plus courantes et exemple de test avec ereg()


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $EXP_num = "^[0-9]+$";
  4. $EXP_num_fixe = "^0262([0-9]){6}$";
  5. $EXP_num_portable = "^069(2|3)([0-9]){6}$";
  6. $EXP_cp = "^974([0-9]){2}$";
  7. $EXP_mail = "^([a-z0-9._-])+@([a-z0-9.-])+(.)([a-z]){2,4}$";
  8. $EXP_nom = "^[a-zA-ZéçèàêëîïôöûüâäÉÀÈËËÏÎÖÔÛÜÄÂ'-][a-zA-ZéçèàêëîïôöûüâäÉÀÈËËÏÎÖÔÛÜÄÂ' -]{2,50}$";
  9. $EXP_date = "^[0-9]{2}/[0-9]{2}/[0-9]{4}$";
  10. $EXP_url = "^http://";
  11. $EXP_alphanum = "^[a-zA-Z0-9_-]$";
  12.  
  13. if(!ereg($EXP_mail, $mail)){ echo "your mail is invalid"; }
  14.  
  15. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.