in Projects, Programming, Technology

gsub is powerful One of these days I really have to get better at regular e…

gsub  is powerful

One of these days I really have to get better at regular expressions

    output = description
  
    unless output.nil?
      r = /src=\"?(http:\/\/[^\s\">]*)/
      output.gsub!(r){|s| "src=\"/images/?src=#{CGI::escape($1)}" }
    end
   
    output
 

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.