Find URLs in Text description With Regex PHP

Saturday, 20. October 2012

This little regex script gives you another simple way to fetch for all possible URLs embedded as simple text in a your rather large description text.

It’s flexible and you can add more filters appropriate for your requirement as you wish..

# take it to the test!
$matches = null;
$returnValue = preg_match_all('%(https://|http://|www)[a-zA-Z0-9\/#&-_\.]+%', $desc_variable, $matches);
# see what you got!
var_dump($matches);

Enjoy!

Tags: , .

Leave a Reply

You must be logged in to post a comment.