fork download
  1. <?php
  2.  
  3.  
  4.  
  5. $input = "+ 7-(925)- 455-41 - 23";
  6. $check = '#^(\\-|\\(|\\)| )*(([+](\\-|\\(|\\)| )*7)|8)((\\-|\\(|\\)| )*[0-9]){10}$#';
  7. if(preg_match($check, $input)){
  8. echo "Верно\n";
  9. }else{
  10. echo"Ошибка\n";
  11. }
  12. $zamena = '#[(\\-|\\(|\\)| )*(([+](\\-|\\(|\\)| )*7)](\\-|\\(|\\)| )*#';
  13. $output = preg_replace($zamena, +7, $input);
  14. echo $output;
Success #stdin #stdout #stderr 0.01s 24192KB
stdin
Standard input is empty
stdout
Верно
stderr
PHP Warning:  preg_replace(): Compilation failed: unmatched parentheses at offset 33 in /home/TlR5Xj/prog.php on line 14