re = /E(\d+)\.tiff?$/m
str = 'D_Passaic_F01_NBR_E0003.tif
D_Passaic_F01_NBR_Eabcd.tif
D_Passaic_F01_NBR_1234.tif
D_abcd_E1234.tif
E_abcd_E1234.tif'
# 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