Ruby linkify for urls in strings
问题 There have been a few posts about linkifying text using a regex. The most popular is this post. However my spec is a little more tricky: describe TextFormatter do def l(input) TextFormatter.gsub_links!(input){|link| "!!#{link}!!"} end it "should detect simple links" do l("http://www.cnn.com").should == "!!http://www.cnn.com!!" end it "should detect multi links" do l("http://www.cnn.com http://boats.com?help.asp").should == "!!http://www.cnn.com!! !!http://boats.com?help.asp!!" end it "should