Hi , I trying to search and replace all urls on a HTML string using gsub .
CODE html = "<a href='http://site.com.br'><img src='http://site3.com/ image.jpg'></a><a href='http://newx.com.br'><img src='http://localhost/ imagem.jpg'></a>"; pattern = /<a href=[\'"]?([^\'"> ]*)[\'"]?[^>]*>(.*?)<\/a>/mo replace = "<a href='http://mysite.com/redirect/#{$1}'>#{$2}</a>" html_output = html.gsub(pattern,replace) The REGEX pattern is apparently working but I 'm not getting the values of $1 and $2 . When I use \\1 and \\2 it works . Thing is ... I need to encode $1 variable like this replace = "<a href='http://mysite.com/redirect/#{Base64.encode64 ($1)}'>#{$2}</a>" and I not able to encode \\1 Can anyone help me ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---