From: Peter Ehrlich Date: 2009-08-11T00:14:00+09:00 Subject: Linking text with regex Hi This is probably a silly question, but I'm wondering what the best way is to scan a string for regular expression matches, and then link to it. It would be great to do it in one line, like this: <% text.sub!(/#[-'A-Za-z]+/, link_to($&, tweet.category_name))%> But as the sub! has not completed, $& still refers to the old variable. I suppose I can just find the text I will be matching ahead of time, which would involve scanning the string twice, but there might be a better way. Thoughts? Thanks in advance!! --Peter -- Posted via http://www.ruby-forum.com/.