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

Php Form validation with Error messages with Checking fields.

Simple calculator using JQuery and HTML..

how to customize dashboard in active admin gem in rails 4