Navindra Umanee wrote: >Hi, > >I have strings of the form: > >string='.///root/1068663688//1068824962/1068836207//1068932537///' > >Basically, I want to extract the last number in the string. > >Right now I'm doing: > >string[/(\d*)\/*$/].delete('/') > >But I've already matched the digit I want, so the delete is just >superfluous work. How can I extract the number without doing a >separate delete? > >Thanks, >Navin. > > > > > class String def str_replace(what,with) re = Regexp.new(Regexp.quote(what)) self.gsub(re) {with} end def str_ireplace(what,with) re = Regexp.new(Regexp.quote(what), Regexp::IGNORECASE) self.gsub(re) {with} end end string='.///root/1068663688//1068824962/1068836207//1068932537///' string = string.str_replace('///','') string = string.str_replace('//','/') temp = string.split('/') return temp[4] regards Eko