This question has already been answered:
- Make the link clickable 1 answer
This code will make from the address http://example.ru/usr/about in the text a link in the following form <a href="http://example.ru/usr/about">example</a> . That is, the link leads to the correct resource but the description is not formed correctly. Minuses (-) and, perhaps, other characters are for some reason discarded. Help make the link look like the right kind
$ctext = preg_replace( '/(http)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a target="_blank" rel="nofollow" href="\0">\4</a>', $ctext ); Here is the test code, not to be unfounded http://ideone.com/HGfnd