re = /\.[A-Za-z]+\.\d+/m
str = 'aaa/prt001.prt.1
aaa/prt001.prt.2
aaa/prt001.prt.3
aaa/prt001.prt.4
aaa/prt001.prt.5
aaa/prt001.prt.10
aaa/prt001.asm.1
aaa/prt001.asm.2
aaa/prt001.asm.3
aaa/prt001.txt.10
aaa/prt001.txt.20
aaa/prt001.txt.30
bbb/prt001.prt
bb/prt.001.prt
bb/prt.001.prt.1
bb/prt.001.1
bb/prt.ppp.prt'
# 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