fork(1) download
  1. <?php
  2.  
  3. $text = '89115065656';
  4. $text2 = '8(911)-506 56 56';
  5. $text3 = '8-911-50-656-56';
  6. $text4 = '89115065656 позвать Люду';
  7. $regexp = '/^[0-9](\\(?)(\\-?)([0-9]{3})(\\)?)(\\-?)([0-9]{2})(\\-?)[0-9](\\s?)([0-9]{2})(\\s?)(\\-?)([0-9]{2})$/';
  8.  
  9. if (preg_match($regexp, $text)) {
  10. echo "Верно\n";
  11. } else {
  12. echo "Неверно\n";
  13. }
  14. if (preg_match($regexp, $text2)) {
  15. echo "Верно\n";
  16. } else {
  17. echo "Неверно\n";
  18. }
  19. if (preg_match($regexp, $text3)) {
  20. echo "Верно\n";
  21. } else {
  22. echo "Неверно\n";
  23. }
  24. if (preg_match($regexp, $text4)) {
  25. echo "Верно\n";
  26. } else {
  27. echo "Неверно\n";
  28. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Верно
Верно
Верно
Неверно