re = /(^\-?0[\,\.][0-9]{1,}$)|(^\-?[1-9][0-9]{1,}$)|(^[0-9]$)|(^\-?[1-9][0-9]{0,}[\,\.][0-9]{1,}$)|(^\-?[1-9]$)/m
str = '01
001
033
0000033
00000.2
00000000000000
01010101010
0000.0
aaa
???!!!!!
111%$$$$
-0
-
-100
-100.255
-10.25555
-1.2
-1335354.12
-22
-2
-1
-13353544366564547
-0.22222298
-0.2
-0,2989080
-6767676767676767677676767677676
-0.22
-123
-1
100.255
10.25555
1.2
1335354.12
22
2
1
13353544366564547
0.22222298
0.2
0,2989080
6767676767676767677676767677676
0
0.22
123'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html