3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(?<!\S)\+?0*(?:91-)?\K(?:91)?[6-9][0-9]{9}(?!\S)/m'; $str = '+918877665544 test 0918877665544 0000918877665544 test +91-8877665544 test 91-8877665544 test 00008877665544 test +91-88776655440 91-88-77665544 +818877665544 0918877665544 0000918877665544 +91-8877665544 92-8877665544 00002877665544'; preg_match_all($re, $str, $matches); print_r($matches[0]);

preferences:
27.77 ms | 405 KiB | 5 Q