Welcome Guest, Not a member yet? Register   Sign In
php grab http or www links from text and return full url
#11

[eluser]new_igniter[/eluser]
ok, I have been working hard on this, but am guessing on something now and would love your help to complete this.

This is the scenario. I have a text blog, and am looking through it for things that start with http or www and then grabbing the matches. I can get it to get the domain, but I need the full URL, like anything after the .com, or .net etc... Is there anyway to adjust this regex so that it looks for anything that starts with the http or www and grabs everything until there is a space?

Code:
if(preg_match("/(http:\/\/)((www\.)|([a-z0-9A-Z]\.)+)?(([a-z0-9A-Z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]+)?)){2,}\.([a-zA-Z]){2,3}\/?/",$text,$hma\
tches))
            {
                echo $hmatches[0];
            }


Messages In This Thread
php grab http or www links from text and return full url - by El Forum - 10-09-2008, 09:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB