fork(3) download
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. $regexp = "/^\s*(([+]\s*7)|8)\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*[0-9]\W*$/um";
  7.  
  8. $correctNumbers = array();
  9. $incorrectNumbers = array();
  10.  
  11. $numbers = array( '84951234567', '+74951234567', '8-495-1-234-567',
  12. ' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67',
  13. '8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567',
  14. '8 ( 999 ) 1234567', '8 999 123 4567','02', '84951234567 позвать люсю', '849512345', '849512345678',
  15. '8 (409) 123-123-123', '7900123467', '5005005001', '8888-8888-88',
  16. '84951a234567', '8495123456a',
  17. '+1 234 5678901',
  18. '+8 234 5678901',
  19. '7 234 5678901' );
  20.  
  21. foreach ($numbers as $num) {
  22. if (preg_match($regexp,$num,$correctNumbers)) {
  23. foreach ($correctNumbers as $corrNum) {
  24. echo " $corrNum \n";
  25. }
  26. }
  27. }
  28.  
  29.  
  30.  
  31. ?>
  32.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
 84951234567 
 8 
 +74951234567 
 +7 
 +7 
 8-495-1-234-567 
 8 
  8 (8122) 56-56-56 
 8 
 8-911-1234567 
 8 
 8 (911) 12 345 67 
 8 
 8-911 12 345 67 
 8 
 8 (911) - 123 - 45 - 67 
 8 
 + 7 999 123 4567 
 + 7 
 + 7 
 8 ( 999 ) 1234567 
 8 
 8 999 123 4567 
 8