On Jul 11, 2008, at 10:05 AM, Max Williams wrote: > On our site, our resources have a description, which is often copied > and > pasted from somewhere else. Often these descriptions have urls in > them, > just as normal text, and i'd like to automatically make these into > working links. > > I was thinking of using gsub as below: > > def description_with_links > regex = ???? > self.description.gsub(regex) {|url|"<a href=\'#{url}'>#{url}</a>"} > end > > The above should work ok, once i have the regex but i can't work it > out. > Can anyone help? > > thanks > max > -- > Posted via http://www.ruby-forum.com/. cfp:~ > cat bin/uris #! /usr/bin/env ruby require 'uri'; protocols = %w[http ftp]; while line = gets; protocols.map{|pr| URI::extract(line, pr) }.flatten.compact.each{|uri| puts uri }; end cfp:~ > curl -s http://codeforpeople.com|uris http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd http://www.w3.org/1999/xhtml http://codeforpeople.com/jquery.js http://drawohara.tumblr.com/ http://rubyforge.org/projects/codeforpeople http://ithmezipper.net/ http://sciruby.codeforpeople.com http://groups.google.com/group/comp.lang.ruby/search?q=cat+a.rb+howard&start=0&scoring=d (thanks manveru ;-)) a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama