get meta description , title and image from url like facebook link sharing
Why are you using regular expression for parsing the <meta>
tags ?
PHP has an in-built function for parsing the meta information , it is called the get_meta_tags()
Illustration :
<?php
$tags = get_meta_tags('http://www.stackoverflow.com/');
echo "<pre>";
print_r($tags);
OUTPUT:
Array
(
[twitter:card] => summary
[twitter:domain] => stackoverflow.com
[og:type] => website
[og:image] => http://cdn.sstatic.net/stackoverflow/img/[email protected]?v=fde65a5a78c6
[og:title] => Stack Overflow
[og:description] => Q&A for professional and enthusiast programmers
[og:url] => http://stackoverflow.com/
)
As you can see the title , image and description are being parsed which you really want.
I know the question is 1.5 years old. But if you are still looking for it, you can use https://urlmeta.org. Its a free API to extract URL meta.