re = /^([AC-FHKNPRTV-Y]\d{2}|D6W)\s[0-9AC-FHKNPRTV-Y]{4}$/m
str = 'D6W 1234
A23 0984
D00 AV92
Y63 1FHK
A00 0000
D44 N4X4
A65 F4E2
D6W FNT4
T37 F8HK
D14 N2Fz
a65 f4e2
D6W FNTO'
# 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