> --snip--
 > #--------------------------------------
 > str = "A link to http://ruby-lang.org"
 >
 > res = 
str.gsub(/([\s|\>|\[|\(])((ftp:\/\/|http(s?):\/\/))([\w\.\?\/&=\-~:%]+)\b/i) 
do
 >     "#{$1}<a href='#{$3}#{$5}#{$6}' target='_blank'>#{$5}#{$6}</a>"
 > end
 >
 > puts res  #-> A link to <a href='http://ruby-lang.org' 
target='_blank'>ruby-lang.org</a>
 > #--------------------------------------

daz,

Thanks for the explanation. That works great.

Dan