fork download
  1. <?php
  2.  
  3.  
  4. $inputData ='8-911-404-44-11';
  5. $regexp ='!8-?\\(?-?[0-9]{3}\\)?-?[0-9]{3}-?[0-9]{2}-?[0-9]{2}$!';
  6. $regexp1 ='![^0-9]!';
  7. $regexp2 ='!\\+7-?\\(?-?[0-9]{3}\\)?-?[0-9]{3}-?[0-9]{2}-?[0-9]{2}$!';
  8. if (preg_match($regexp, $inputData)) {
  9. $result =preg_replace($regexp1, '', $inputData);
  10. echo $result;
  11.  
  12. } else {
  13. if (preg_match($regexp2, $inputData)) {
  14. $result =preg_replace($regexp1, '', $inputData);
  15. echo $result;
  16. } else {echo "Пожалуйста введите номер в верном формате.\n";
  17. }
  18. }
  19.  
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
89114044411