From: Antonio Cangiano Date: 2006-02-05T20:48:19+09:00 Subject: Re: Scanning a string for decimal numbers Jeppe Jakobsen wrote: > Hi all, how do you scan a string and avoid getting my decimal numbers > divided into 2 numbers. > > Example: > > a = "24,4 + 55,2" > a.scan! (/\d+/) > puts a > > my output for a will be: > 24 > 4 > 55 > 2 > > But I want to keep my decimal numbers intact like this: > 24,4 > 55,2 > > > How do I solve this problem without putting the numbers into seperate > strings? Hi Jeppe, you can use the following: a.scan /[-+]?[0-9]*\,?[0-9]+/ which will take care of negative numbers as well. HTH, Antonio -- Zen and the Art of Ruby Programming http://www.antoniocangiano.com