re = /^((qwarebatch[0-9]?_((g?p(tres|[fse])|lc|ra|darf?|n[edlcs]|ob|gru_intra))_)|([AG]F|[EL]?[CO]([ACDV])?|D[CIL]|NT))[0-9]{5,8}\.TXT.*/im
str = 'qwarebatch_nc_20140714.TXT
AF32503.txt
CV4130214.TXT
CA5070515.TXT
CD4130115.txt
CC4130214.TXT
DI41102.txt
qwarebatch_dar_20150602.TXT
qwarebatch_darf_20150602.TXT
DC4130214.TXT
DL4160214.TXT
EC5070515.TXT
GF41102.txt
GP41102.TXT
qwarebatch_gru_intra_20150602.TXT
qwarebatch_lc_20150602.TXT
LO4130214.TXT
NT32503.txt
qwarebatch_nd_20150602.TXT
qwarebatch_ne_20150602.TXT
qwarebatch_nl_20150602.TXT
qwarebatch_ns_20150602.TXT
qwarebatch_ob_20150602.TXT
qwarebatch_pe_20140618.TXT
qwarebatch_pf_20150602.TXT
qwarebatch2_ptres_20150602.TXT
qwarebatch_ra_20150602.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