fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $text = "+7(919)-122-88-99";
  6. $result = null;
  7.  
  8. $userInputRegexp = '/^(8|[+]7)[\\(\\)0-9-]{10,40}/u';
  9. $filterRegexp = '/[\\(\\)-]/u';
  10. $changeFirstNumberRegexp = '/[+]7/u';
  11.  
  12. if (preg_match($userInputRegexp,$text)){
  13. $result = preg_replace($filterRegexp,"",preg_replace($changeFirstNumberRegexp,"8",$text));
  14. echo $result;
  15. } else
  16. echo "Wrong number!";
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
89191228899