INPUT: a string containing decimal numbers. OUTPUT: an array containing all the decimal numbers within the given string. You can accomplish this task very quickly with the String#scan method and the right Regular Expression (regex). Given a string s, you can use: numbers = s.scan /[-+]?\d*\.?\d+/ numbers will be an array whose elements are
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.