Print the numbers on given array using Regular Expressions.




#Print the three digit numbers in given array

my_array = [111,45456,456,74897,787,45466,789,6587,784,234,456,4658,4587,235,456]
my_reg = []
my_array.each do |k|
my_reg << my_array
end
if my_reg=my_array.select {|n| n.to_s.match(/^\d{3}$/)}
puts my_reg

end

Comments

Popular posts from this blog

how to customize dashboard in active admin gem in rails 4

fibonacci series in Ruby

Simple calculator using JQuery and HTML..