How to replace a url with a link to it with regular expressions
By liviu - Posted on May 6th, 2009
Tagged:
If you want to replace all the url's in a text with a link to them you should do something like this:
$text = preg_replace'@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
Bookmark/Search this post with:
- liviu's blog
- Login or register to post comments
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket