Replacing the urls in a block of plain text is done by looking for url regular expressions. I开发者_Go百科 am using string.gsub(regex, "\1") to achieve the same.
I would like to know how to proceed if the shortened url (using api's of any url shortening service) is to be used as the replacement and not the original url.
I am using Ruby.
gsub(regex) {|url| shorten_url(url)}
Where shorten_url is a method that takes a url and returns a shorter url as a string suppled by a url shortening service.
精彩评论