I have a function that is intended to replace urls having the formats below with an appropriate link.
http://yahoo.com
http://www.yahoo.com
www.yahoo.com
Also the regex should ignore existing anchors.
This works but doesn't ignore the anchors:
$this->data[$name] = eregi_replace("(((http://)(www.)?)|(www.))([a-z0-9-]+(.[a-z0-9-]+)(.[a-z]{2,3})((/|\?)[a-z0-9~#%&\/'_+=:\?.-])*)", "<a href=\"http://www.\6\">\0</a>", $this->data[$name]);
So I tried to require the url string to start with either http:// or www. by adding a ^ at the beginning of the expression. This ignores anchors but does only replace urls starting with http://www.
I hope you'll be able to help me out :-)