-------------------------------1149158032
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

 
In einer eMail vom 01.06.2006 12:21:49 WesteuropçÊsche Normalzeit schreibt20
iiskakov / gmail.com:

How I  can simplify it:
params[:value] =~  /^\d+$|^-\d+$|^\d+\.\d+$|^-\d+\.\d+$/



OK, so, you want to extract the numbers that can by either floats or  
integers from some
text.
You can use a * after something you don't necessarily need in your Regexp,  
and you can
use that on groups of characters, enclosed in brackets:
 
 

text='my bank account is -100000000.09 dollars, but I earn 1 dollar a  day, 
which is better than earning 0.50 dollars or 0 dollars.'
words=text.split
numbers=[]
words.each{|x|
if x=~  /^\-*\d+(\.\d+)*$/
numbers<<x
end
}
p 'all the numbers that  were there:'
p numbers
 
Best regards,
 
Axel 

-------------------------------1149158032--