Skip to content

Instantly share code, notes, and snippets.

@nitsujw
Created March 1, 2009 00:04
Show Gist options
  • Save nitsujw/72154 to your computer and use it in GitHub Desktop.
Save nitsujw/72154 to your computer and use it in GitHub Desktop.
## If the matched image has a "?" as part of the source the gsub fails
## http://example.net/test.jpg <-- Does get gsub'd
## http://example.net/test.jpg?624332 Doesn't get gsub'd
imgs = self.body_html.scan(/\[img\](.*?)\[\/img\]/i)
imgs.each do |img|
body_html.gsub!(/\[img\]#{img[0]}\[\/img\]/i, "<img src=\"#{img[0]}\" />")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment