p "-1.2 56 0.443 4.22E-12 000555".scan( /(?:[+-])?[0-9]+(?:[,.][0-9]+)?(?:E[+-][1-9][0-9]*)?/ ) #=> ["-1.2", "56", "0.443", "4.22E-12", "000555"] This looks okay for most purposes, in my opinion. :) You can google for "real number regex" et cetera... Daniel Baird schrieb: >> > On 8/4/06, Robert Retzbach <rretzbach / googlemail.com> wrote: >> > > What about "1a2+b".scan(/\d+) ? >> > > It returns the numbers as array. >> >> Will this pick up negative numbers or floats? >> > > Nope, only plain digits. if you want other stuff, you need to add it > to the regex. > /\d+/ ..is just digits > /[+-]?\d+/ ..optional + or - > /[+-]?\d+\.?\d*/ ..optional + or -, and optional . > > untested.. (sorry, too lazy to test :) >