re = /[0-9]{1,5}/m
str = '6004
281
2812
89112
23
02891
7821
28199
96822
56615
44261
60928
72912
527
910
0011
11111'
# 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