re = /^[a-z]*\d[a-z]*?(?<=^.{5}$)/m
str = 'jlwk6
bjkgp
5fm8s
x975t
k88q5
zl796
qm9hb
h6gtf
9rm9p
jwzw2
jlwk6a
bjkgpa
5fm8sa
x975ta
k88q5a
zl796a
qm9hba
h6gtfa
9rm9pa
jwzw2a'
# 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