Here''s a hpricot example that works:
require ''rubygems''
require ''hpricot''
doc = Hpricot("<html><body><p><img
src=\"/2010-01-12/Capture/1210420100112145725141.jpg\"
/></p></body></html>")
doc.search(''img'').each do |img|
img[''src''] =
img[''src''].gsub(/^\/\d{4}-\d{2}-\d{2}/, "") # have
to do gsub
– gsub! doesn''t work
end
puts doc.html
Anyone, if this can be done smarter, please write.
--Lasse
2010/2/15 Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> Dear all,
>
> i have a html file in my local path.
>
> In that html file i have below tag.
>
> <img src="/2010-01-12/Capture/1210420100112145725141.jpg"
/>
>
> Now what i need is i want to modify the above tag into
>
> <img src="/Capture/1210420100112145725141.jpg" />
>
> i want to replace all the image path like above path.
>
> Is it possible to do? i have a idea in hpricot parser.
>
> Is it worth to try with hpricot..
>
> if so,kindly provide any sample code or links
>
> Thank you for your time
> --
> Posted via ruby-forum.com.
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
groups.google.com/group/rubyonrails-talk?hl=en.