re = /\d{8}[A-Z]\d{5}/
str = '123456789
987654321
987654322
987654323
98765432A12312
987654325
987654326
987654327
987654328
987654329
666218502
773218502
772218502
443218502
641218502
525.52.6969B
515-54-6976-A
555516316S
123.45.6789
987.65.4321
987.65.4322
987.65.4323
987.65.4324
987.65.4325
987.65.4326
987.65.4327
987.65.4328
987.65.4329
666.21.8502
773.21.8502
772.21.8502
772-21-8502
772218502
443.21.8502
641.21.8502'
# Print the match result
str.match(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