Two tiny problems with it. I love it Twey, but I noticed it was missing a \.
Code:
$text = preg_replace('/https?:\\/\\/([-_.\\/\w\d!&%#?+\\,\\\\\'=:;@~]+)/i', '<a href="$1">$1</a>', $text);
I really am only an elementary student of this stuff. There needs to be an alternate statement to allow for missing 'http://' in case a person left that out.
Even when using the code listed with the '/' put in I get:
Code:
$text="http://www.what.com"
http://www.mysite.com/www.what.com
Where mysite is the webmaster's address.
EDIT: Part of the problem seems to be on my end. I am not sure why my links are all being prefaced with my website's url.
EDIT: nvm. problem fixed, but still having trouble with the regular expression.
EDIT: kk, got it. Try the following:
PHP Code:
$text = preg_replace('/https?:\\/\\/([-_.\\/\w\d!&%#?+\\,\\\\\'=:;@~]+)/', '<a href=http://$1>$1</a>', $text);
I changed <a href="$1"> to <a href=http://$1> Gonna add this one to my collection. It is a pretty cool idea, thanks 
I almost have the one for the www.site.com addresses where there is no "http://" typed in, but I can't quite figure out how to remove the . in front of the hyperlinked text. Otherwise it works except for the cosmetic problem.
PHP Code:
$text = preg_replace('/wwws?([-_.\\/\w\d!&%#?+\\,\\\\\'=:;@~]+)/', '<a href=http://www$1>$1</a>', $text);
Anyone know how to work out the bugs? For example the two don't seem to work together.
Bookmarks