Automate Linking To Twitter Users
Join the DZone community and get the full member experience.Join For Free
this method searches for @some_user in a string (txt) and links found matches to the twitter-page of some_user
def link_twitter_user(txt) if match = txt.match(/.*?(@)((?:[a-z][a-z]+))(:|\s)/i) user = match txt.gsub!(user, '' + user + '') end txt end
Opinions expressed by DZone contributors are their own.