From: Saeed Bhuta Date: 2010-03-24T23:10:54+09:00 Subject: Re: Manipulating an Array Element Rob Biedenharn wrote: > On Mar 24, 2010, at 9:28 AM, Saeed Bhuta wrote: > >>>> string manipulation >>> Provide more details, get more help :) >> >> #puts images >> >> #go through images names to get platform number >> images.each { |img| >> img.to_s >> #extract characters one to four from image name >> img[0,4] > > Assuming your problem is here^ > > img.to_s does not convert the image to a string (img is a dom element, > right?) > > Try something like img.to_s[0,4] or img['src'][0,4] (but please look > in the documentation for Hpricot to see how to get the part you want > as a string). > > -Rob > >> Posted via http://www.ruby-forum.com/. >> > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com Thanks Rob, I did: platNo = img['src'].to_s #extract the platform number from the image name puts platNo[1,1] And it returns the value I need. Once again, many thanks. Saeed -- Posted via http://www.ruby-forum.com/.