I need to write a method such that when we pass on a string to it, it
returns a substring out of it. returned string is such that it
consists of numerals only. All the characters other than numerals are
stripped away.

e.g.
" 2009-05-30 10:25:15 UTC"  ==> 20090530102515

I have written the following method for the same.
It seems to be working but I am looking for your suggestions /
feedback for
  --> performance improvment
  --> any bug that i am not able to see


def getNumeralString(istr)
    x = istr.split(//)
    istr = ""
    x.each{|a|
      if a[0] >= '0'[0]   && a[0] <= '9'[0]
        istr = istr +a
      end
    };
  return istr
end


Thanks for feedback

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to