I found a function online for turning a url within a string into a clickable link. However, when the url contains a hashtag it doesn't work. eg. http://www.bbc.co.uk/radio1/photos/fearnecotton/5759/1#gallery5759
Here's the part of the function concerned:
$ret = preg_replace(
"#(^|[
])([\w]+?://[\w]+[^ \"
\t< ]*)#",
"\\1<a href=\"\\2\" target=\"_blank\">\\2</a>",
$ret
);
$ret = preg_replace(
"#(^|[
])((www|ftp)\.[^ \"\t
< ]*)#",
"\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>",
$ret
);
Any ideas? thanks