fork download
  1. <?php
  2.  
  3. header("Content-Type: text/plain; charset=utf-8");
  4.  
  5. $input = '8(911)596-55-55';
  6. $regexp = '/^8[(\s]{1}[0-9]{3}[)\s]{1}[0-9]{3}[-\s]{1}[0-9]{2}[-\s]{1}[0-9]{2}$/';
  7. $matches = array();
  8.  
  9. if (preg_match($regexp, $input, $matches)) {
  10. echo "Все верно. \n";
  11. var_dump($matches);
  12. } else {
  13. echo "Не верно. \n";
  14. }
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
Все верно. 
array(1) {
  [0]=>
  string(15) "8(911)596-55-55"
}