re = /^((0|1)[0-9])\/([0-3][0-9])\/([0-9][0-9])/m
str = '01/01/20
02/01/20
03/01/20
04/01/20
05/01/20
06/01/20
07/01/20
08/01/20
09/01/20
10/01/20
11/01/20
12/01/20
01/32/20
01/03/20
01/04/20
01/05/20
01/06/20
01/07/20
01/08/20
01/09/20
01/10/20
01/11/20
01/12/20
01/13/20
01/14/20
01/15/20
01/16/20
01/17/20
01/18/20
01/19/20
01/20/20
01/21/20
01/22/20
01/23/20
01/24/20
01/25/20
01/26/20
01/27/20
01/28/20
01/29/20
01/30/20
01/31/20
'
# 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