I am trying to get the phone number between the plain text. But here, I am facing some typical problem. The pattern which I have written is not matching all types of phone numbers.
Ex:
$string = 'sample text sample text sample text (216) 499 1001 sample text sample text (262) 335 60 76-77 sample text sample text sample text';
$string = str_replace('\n', PHP_EOL, $string);
//my regex pattern
$regex = '/(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})(?:(?<=\(\d{3})\))? ?(?:(?<=\d{3})[.-])?([2-9]\d{2})[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?\s+?/';
preg_match_all($regex, $string, $matches);
print_r($matches);
which is giving me the first phone number , but not the second one. Plz help me in getting that pattern also.
Output:
Array
(
[0] => Array
(
[0] => (216) 499 1001
)
----
---
Thanks in advance!