Hello Every one.. i need regular expression to replace a url with link. consider $text=welcome to http://www.mysite.com continue with some content jst my need is $text=welcome to <a href="http://www.mysite.com">http://www.mysite.com</a> continue with some content... i tried $text=preg_replace('@(https?://([-\w\.]+)+\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text); but it womits the url after a hypen(-) presents ex http://www.mysite.com/test-link will went to http://www.mysite.com/test help me in this issue,,, thanks
$text = "welcome to http://www.mysite.com continue with some content"; $search = "/(http[s]*:\/\/[\S]+)/"; $replace = "<a href='\${1}'>\${1}</a>"; $output = preg_replace($search, $replace, $text) PHP: