re = /(?:INSERT_|UPDATE_)?([NY|80]{2}[0-9]{6})_([^0-9]*)_([0-9]{4})_06_30\.(?:txt|csv)/m
str = 'UPDATE_80070175_LOCATION_MARKING_PERIOD_2020_06_30.txt
INSERT_80070175_STUDENT_CLASS_GRADE_DETAIL_2020_06_30.txt
INSERT_80070175_STUDENT_CLASS_ENTRY_EXIT_2020_06_30.txt
INSERT_80070175_STUD_ATTEND_DAY_2020_06_30.txt
INSERT_80070175_PROGRAMS_FACT_2020_06_30.txt
INSERT_80070175_DAY_CALENDAR_2020_06_30.txt
INSERT_80070175_CRSE_INSTRUCT_ASSIGNMENT_2020_06_30.txt
INSERT_80070175_COURSE_2020_06_30.txt
INSERT_80070175_ATTENDANCE_CODES_2020_06_30.txt
80070175_STUDENT_LITE_UPDATE_2020_06_30.txt
80070175_SCHOOL_ENTRY_EXIT_INSERT_2020_06_30.txt
'
# 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