i am using php and wants to extract phone/mobile numbers from string, i have string with multiple format of phone numbers like
$str = '(123) 456-7890 or (123)456-7890 and 1234567890 test "123.456.7890" another test "123 456 7890"';
i had write one RE
as,
$phoneMatches = '';
$str = '(123) 456-7890 or (123)456-7890 or 1234567890 or "123.456.7890" or "123 456 7890"';
$phonePattern = '/\b[0-9]{3}\s*[-]?\s*[0-9]{3}\s*[-]?\s*[0-9]{4}\b/';
preg_match_all($phonePattern, $str, $phoneMatches);
echo "<pre>";
print_r($phoneMatches);
exit;
but it gives me output like this,
Array
(
[0] => Array
(
[0] => 1234567890
[1] => 123 456 7890
)
)
Means only two, but i want all the possible combination of phone numbers and mobile numbers from string of text by using only ONE Regular expression.
Thanks