re = /7(?:1(?:7(?:24|3[01]|4[79]|5[089]|6[258])|8(?:3[49]|40|54)|9(?:0[1239]|1[034]|37|49|5[16]|6[48]))|2087|55(?:0[13457]|59|6[179]|7[034]|99))%/
str = '71901%
71902%
71903%
71909%
71910%
71911%
71912%
71913%
71914%
71949%
71950%
71951%
71956%
71964%
71968%
72087%
71834%
71937%
71839%
71840%
71854%
71724%
71730%
71731%
71747%
71749%
71750%
71758%
71759%
71762%
71765%
71768%
75501%
75503%
75504%
75505%
75507%
75559%
75561%
75567%
75569%
75570%
75573%
75574%
75599%
'
# 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