re = /(?<a1>\d{10})_(?<a2>\d{10})_(?<a3>\d{10})_(?<a43>\d{10})_(?<a5>\D{4})_(?<a6>\d{2}).(?<a7>\d{2}).(?<a8>\d{4})_(?<a9>\D{2})_(?<a10>\d{2}).(?<a11>\d{2}).(?<a12>\d{4})_(?<a13>\d+).(?<a14>\D{3})/
str = '2016001597_0002541747_0002581681_0054699343_From_07.31.2016_To_07.31.2016_2.PDF'
# 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